Hi,
I am trying to build a
JSP page which uses a
Java Class to set and get values. I am running default root application.I have put the JSP file (ShowCustName.jsp) under ROOT and the Java class(CustomerName.class) under ROOT\WEB-INF\classes. But when I call the page it gives me following error.Normal jsp which doesnot call any Java class works fine.
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 7 in the jsp file: /ShowCustName.jsp
Generated
servlet error:
CustomerName cannot be resolved or is not a type
An error occurred at line: 7 in the jsp file: /ShowCustName.jsp
Generated servlet error:
CustomerName cannot be resolved or is not 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:389)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
----ShowCustName.jsp -----
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
Show Customer Name
</head>
<body>
<% CustomerName custname = new CustomerName();
custname.setFirstName("Nitin");
custname.setLastName("Kumar"); %>
First Name :<%= custname.getFirstName() %>
Last Name : <%= custname.getLastName() %>
</body>
</html>
--- CustomerName.java --
public class CustomerName {
private
String firstName;
private String lastName;
public String getFirstName(){
return firstName;
}
public void setFirstName(String firstName){
this.firstName=firstName;
}
public String getLastName(){
return lastName;
}
public void setLastName(String lastName){
this.lastName=lastName;
}
}
I have tried setting the CLASSPATH to WEB-INF\classes but in vain.
Can any body help me out?