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.
--------------------------------------------------------------------------------
---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.
--------------------------------------------------------------------------------
<%@ 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;
}
}
fb.setfirstproperty("my first");
% >
<%=fb.getfirstproperty()% >
</html >
改了也用JSP动作看看
fb.setfirstproperty("my first");
% >
<%=fb.getfirstproperty()% >
</html >
改了也用JSP动作看看
~~~~~~~~~~~~~~~~~~~~~~
什么意思啊?语法应该没问题啊
一般javaBean是需要放到一个包里的。
------
解决的办法:
修改firstjavabean.java,添加在一个包中。
jsp页面调用其相应包名+firstjavabean
<jsp:useBean id="fb" scope="session" class="firstjavabean" / >
<html >
应该改成
<%@ page contentType="text/html;charset=gb2312" % >
<html>
<jsp:useBean id="fb" scope="session" class="firstjavabean" / >
所以每次我再通过eclipse启动的时候造成了端口冲突
解决了