D
Dave
I have set-up Apache Tomcat for the first time and I'm trying to configure a
test JSP website on it. I'm attempting to use a simple JavaBean with my JSP
page and I keep getting errors relating to the JavaBean.
index.jsp is in the $CATALINA_HOME\webapps\JSPTest\WebContent
SimpleBean.java is in $CATALINA_HOME\webapps\JSPTest\src\mybeans
SimpleBean.class is in
$CATALINA_HOME\webapps\JSPTest\WebContent\WEB-INF\classes\mybeans
web.xml is in $CATALINA_HOME\webapps\JSPTest\WebContent\WEB-INF\
If I change the "type" attribute of the jsp:useBean tag then to "class" then
I get a different exception (shown below).
I'm using Tomcat 5.5 for Windows, JRE/JDK 1.5. I have tried uninstalling and
re-installing Tomcat, and also tried running it as both a service and a
standalone application.
Any idea what the problem is? I presume it's something fundamental I'm
missing.
Thanks in advance, code and errors are below.
********
index.jsp
********
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="mybeans.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Using SimpleBean</title>
</head>
<body>
<jsp:useBean id="msg" type="SimpleBean" />
Test Content
</body>
</html>
*************
SimpleBean.java
*************
package mybeans;
public class SimpleBean
{
private String message;
public SimpleBean()
{
}
public void setMessage(String input)
{
message = input;
}
public String getMessage()
{
return message;
}
}
*******
web.xml
*******
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>
JSPTest</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>SimpleBean</servlet-name>
<servlet-class>SimpleBean</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SimpleBean</servlet-name>
<url-pattern>/servlet/SimpleBean</url-pattern>
</servlet-mapping>
</web-app>
*********
Exception 1
*********
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: 13 in the jsp file: /WebContent/index.jsp
Generated servlet error:
SimpleBean cannot be resolved to a type
An error occurred at line: 13 in the jsp file: /WebContent/index.jsp
Generated servlet error:
SimpleBean cannot be resolved to a type
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)root causeorg.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 13 in the jsp file: /WebContent/index.jspGenerated servlet error:SimpleBean cannot be resolved to a typeAn error occurred at line: 13 in the jsp file: /WebContent/index.jspGenerated servlet error:SimpleBean cannot be resolved to a type org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414) org.apache.jasper.compiler.Compiler.compile(Compiler.java:297) org.apache.jasper.compiler.Compiler.compile(Compiler.java:276) org.apache.jasper.compiler.Compiler.compile(Compiler.java:264) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)note The full stack trace of the root cause is available in the ApacheTomcat/5.5.20 logs.********Exception 2*********description The server encountered an internal error () that prevented itfrom fulfilling this request.exceptionorg.apache.jasper.JasperException: Unable to load class for JSP org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)root causeorg.apache.jasper.JasperException: Unable to load class for JSP org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:598) org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:147) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)root causejava.lang.ClassNotFoundException: org.apache.jsp.WebContent.index_jsp java.net.URLClassLoader$1.run(Unknown Source) java.security.AccessController.doPrivileged(Native Method) java.net.URLClassLoader.findClass(Unknown Source) org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:133) org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:65) org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:596) org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:147) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)note The full stack trace of the root cause is available in the ApacheTomcat/5.5.20 logs.***************************Exception 3 (using "class" instead of "type" attribute)***************************description The server encountered an internal error () that prevented itfrom fulfilling this request.exceptionorg.apache.jasper.JasperException: /WebContent/index.jsp(13,0) The value forthe useBean class attribute SimpleBean is invalid. org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)root causeorg.apache.jasper.JasperException: /WebContent/index.jsp(13,0) The value forthe useBean class attribute SimpleBean is invalid. org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405) org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:146) org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1174) org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1116) org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163) org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213) org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219) org.apache.jasper.compiler.Node$Root.accept(Node.java:456) org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163) org.apache.jasper.compiler.Generator.generate(Generator.java:3320) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198) org.apache.jasper.compiler.Compiler.compile(Compiler.java:295) org.apache.jasper.compiler.Compiler.compile(Compiler.java:276) org.apache.jasper.compiler.Compiler.compile(Compiler.java:264) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)note The full stack trace of the root cause is available in the ApacheTomcat/5.5.20 logs.
test JSP website on it. I'm attempting to use a simple JavaBean with my JSP
page and I keep getting errors relating to the JavaBean.
index.jsp is in the $CATALINA_HOME\webapps\JSPTest\WebContent
SimpleBean.java is in $CATALINA_HOME\webapps\JSPTest\src\mybeans
SimpleBean.class is in
$CATALINA_HOME\webapps\JSPTest\WebContent\WEB-INF\classes\mybeans
web.xml is in $CATALINA_HOME\webapps\JSPTest\WebContent\WEB-INF\
If I change the "type" attribute of the jsp:useBean tag then to "class" then
I get a different exception (shown below).
I'm using Tomcat 5.5 for Windows, JRE/JDK 1.5. I have tried uninstalling and
re-installing Tomcat, and also tried running it as both a service and a
standalone application.
Any idea what the problem is? I presume it's something fundamental I'm
missing.
Thanks in advance, code and errors are below.
********
index.jsp
********
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="mybeans.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Using SimpleBean</title>
</head>
<body>
<jsp:useBean id="msg" type="SimpleBean" />
Test Content
</body>
</html>
*************
SimpleBean.java
*************
package mybeans;
public class SimpleBean
{
private String message;
public SimpleBean()
{
}
public void setMessage(String input)
{
message = input;
}
public String getMessage()
{
return message;
}
}
*******
web.xml
*******
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>
JSPTest</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>SimpleBean</servlet-name>
<servlet-class>SimpleBean</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SimpleBean</servlet-name>
<url-pattern>/servlet/SimpleBean</url-pattern>
</servlet-mapping>
</web-app>
*********
Exception 1
*********
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: 13 in the jsp file: /WebContent/index.jsp
Generated servlet error:
SimpleBean cannot be resolved to a type
An error occurred at line: 13 in the jsp file: /WebContent/index.jsp
Generated servlet error:
SimpleBean cannot be resolved to a type
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)root causeorg.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 13 in the jsp file: /WebContent/index.jspGenerated servlet error:SimpleBean cannot be resolved to a typeAn error occurred at line: 13 in the jsp file: /WebContent/index.jspGenerated servlet error:SimpleBean cannot be resolved to a type org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414) org.apache.jasper.compiler.Compiler.compile(Compiler.java:297) org.apache.jasper.compiler.Compiler.compile(Compiler.java:276) org.apache.jasper.compiler.Compiler.compile(Compiler.java:264) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)note The full stack trace of the root cause is available in the ApacheTomcat/5.5.20 logs.********Exception 2*********description The server encountered an internal error () that prevented itfrom fulfilling this request.exceptionorg.apache.jasper.JasperException: Unable to load class for JSP org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)root causeorg.apache.jasper.JasperException: Unable to load class for JSP org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:598) org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:147) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)root causejava.lang.ClassNotFoundException: org.apache.jsp.WebContent.index_jsp java.net.URLClassLoader$1.run(Unknown Source) java.security.AccessController.doPrivileged(Native Method) java.net.URLClassLoader.findClass(Unknown Source) org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:133) org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:65) org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:596) org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:147) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)note The full stack trace of the root cause is available in the ApacheTomcat/5.5.20 logs.***************************Exception 3 (using "class" instead of "type" attribute)***************************description The server encountered an internal error () that prevented itfrom fulfilling this request.exceptionorg.apache.jasper.JasperException: /WebContent/index.jsp(13,0) The value forthe useBean class attribute SimpleBean is invalid. org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)root causeorg.apache.jasper.JasperException: /WebContent/index.jsp(13,0) The value forthe useBean class attribute SimpleBean is invalid. org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405) org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:146) org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1174) org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1116) org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163) org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213) org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219) org.apache.jasper.compiler.Node$Root.accept(Node.java:456) org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163) org.apache.jasper.compiler.Generator.generate(Generator.java:3320) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198) org.apache.jasper.compiler.Compiler.compile(Compiler.java:295) org.apache.jasper.compiler.Compiler.compile(Compiler.java:276) org.apache.jasper.compiler.Compiler.compile(Compiler.java:264) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)note The full stack trace of the root cause is available in the ApacheTomcat/5.5.20 logs.