firstbean---src
         ---WebRoot
           --------fbean.jsp
          ---------WEB-INF
                    ------classes
                          -------firstjavabean.class
如果输入http://localhost:8080/firstbean/
可以看到index.jsp的内容
如输入http://localhost:8080/firstbean/fbean.jsp,然后运行出错
              HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 2 in the jsp file: /fbean.jsp
firstjavabean cannot be resolved to a type
1: <%@ page contentType="text/html;charset=gb2312" %>
2: <jsp:useBean id="fb" scope="session" class="firstjavabean" />
3: <html>
4: <%
5: fb.setfirstproperty("my first");
An error occurred at line: 2 in the jsp file: /fbean.jsp
firstjavabean cannot be resolved to a type
1: <%@ page contentType="text/html;charset=gb2312" %>
2: <jsp:useBean id="fb" scope="session" class="firstjavabean" />
3: <html>
4: <%
5: fb.setfirstproperty("my first");
An error occurred at line: 2 in the jsp file: /fbean.jsp
firstjavabean cannot be resolved to a type
1: <%@ page contentType="text/html;charset=gb2312" %>
2: <jsp:useBean id="fb" scope="session" class="firstjavabean" />
3: <html>
4: <%
5: fb.setfirstproperty("my first");
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.
--------------------------------------------------------------------------------

解决方案 »

  1.   

    fbean.jsp代码
    <%@ page contentType="text/html;charset=gb2312" %>
    <jsp:useBean id="fb" scope="session" class="firstjavabean" />
    <html>
    <%
    fb.setfirstproperty("my first");
    %>
    <%=fb.getfirstproperty()%>
    </html>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    firstjavabean.java代码public class firstjavabean {
    private String firstproperty=new String("");
    public firstjavabean()
    {
    }
    public String getfirstproperty()
    {
    return firstproperty;
    }
    public void setfirstproperty(String value)
    {
    firstproperty=value;
    }
    }
      

  2.   

    <% 
    fb.setfirstproperty("my first"); 
    % > 
    <%=fb.getfirstproperty()% > 
    </html > 
    改了也用JSP动作看看
      

  3.   

    <%  
    fb.setfirstproperty("my first");  
    %  >  
    <%=fb.getfirstproperty()%  >  
    </html  >  
    改了也用JSP动作看看
    ~~~~~~~~~~~~~~~~~~~~~~
    什么意思啊?语法应该没问题啊
      

  4.   

    我记的javabean一定要放在一个包里才可以的。 你试试把bean放到一个包里再在jsp页面里去调用试试。
      

  5.   

    楼上的是正解。
    一般javaBean是需要放到一个包里的。
    ------
    解决的办法:
    修改firstjavabean.java,添加在一个包中。
    jsp页面调用其相应包名+firstjavabean
      

  6.   

    你的<%@ page contentType="text/html;charset=gb2312" % > 
    <jsp:useBean id="fb" scope="session" class="firstjavabean" / > 
    <html > 
    应该改成
    <%@ page contentType="text/html;charset=gb2312" % > 
    <html>
    <jsp:useBean id="fb" scope="session" class="firstjavabean" / > 
      

  7.   

    我找到答案了。因为我的tomcat是安装版,设置了每次开机启动
    所以每次我再通过eclipse启动的时候造成了端口冲突
    解决了