Unable to compile class for JSP
Hi this is my opening page
<html>
<head>
<title> Customer Registration </title>
</head>
<body>
<center> <h1> Customer Registration </h1> </center>
<form action = "forward.jsp" method ="Post">
<input type="Submit" name="Submit" value="Submit Request">
</form>
</html>
this forward.jsp
<%@page import="TechSupportBean" %>
<jsp:useBean id="techSupportBean" scope="session" type="TechSupportBean"/>
<jsp:forward page="regForm.jsp"/>
my TechSupportBean.classs is in %tomcat_home%\webapps\tech\WEB-INF\classes
but iam getting the error :
Unable to compile class for JSP
Generated servlet error:
The import TechSupportBean cannot be resolved
please help me out
error:
org.apache.jasper.JasperException: Exception in JSP: /forward.jsp:3
1: <%@page import="myclass.TechSupportBean" %>
2:
3: <jsp:useBean id="techSupportBean" scope="request" type="myclass.TechSupportBean"/>
4:
5:
6: <jsp:forward page="regForm.jsp"/>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:506)
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 cause
javax.servlet.ServletException: bean techSupportBean not found within scope
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:843)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:776)
org.apache.jsp.forward_jsp._jspService(forward_jsp.java:66)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
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 cause
java.lang.InstantiationException: bean techSupportBean not found within scope
org.apache.jsp.forward_jsp._jspService(forward_jsp.java:49)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
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)
Hi this is my opening page
<html>
<head>
<title> Customer Registration </title>
</head>
<body>
<center> <h1> Customer Registration </h1> </center>
<form action = "forward.jsp" method ="Post">
<input type="Submit" name="Submit" value="Submit Request">
</form>
</html>
this forward.jsp
<%@page import="myclass.TechSupportBean" %>
<jsp:useBean id="techSupportBean" scope="session" class="myclass.TechSupportBean"/>
<% if (techSupportBean.isRegistered) { %>
<jsp:forward page="regForm.jsp"/>
<% } %>
and TechSupportBean.class
package myclass;
import java.sql.*;
public class TechSupportBean {
public TechSupportBean() {
}
private boolean registered;
public boolean isRegistered () {
registered = true;
return registered;
}
}
my TechSupportBean.classs is in %tomcat_home%\webapps\tech\WEB-INF\classes\myclass
but iam getting the error :
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 6 in the jsp file: /forward.jsp
Generated servlet error:
techSupportBean.isRegistered cannot be resolved or is not a field
Hi,
I'm getting the following error when trying to update a customer page in my project.I'm using tomcat4.1,orace 10g as database.
type Exception report
message
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: -1 in the jsp file: null
Generated servlet error:
[javac] Compiling 1 source file
C:\apache-tomcat-4.1.34\work\Standalone\localhost\bank\CombinedError_jsp.java:7: package project does not exist
import project.InvalidCustomer;
^
C:\apache-tomcat-4.1.34\work\Standalone\localhost\bank\CombinedError_jsp.java:8: package project does not exist
import project.InvalidAccount;
^
C:\apache-tomcat-4.1.34\work\Standalone\localhost\bank\CombinedError_jsp.java:9: package project does not exist
import project.InvalidAmount;
^
C:\apache-tomcat-4.1.34\work\Standalone\localhost\bank\CombinedError_jsp.java:10: package project does not exist
import project.InsufficientBalance;
^
C:\apache-tomcat-4.1.34\work\Standalone\localhost\bank\CombinedError_jsp.java:11: package project does not exist
import project.ClosedAccountException;
^
5 errors
Here i'm attaching my jsp file
<%--
* This jsp file catches all the exception thrown by the program
* and displays message accordingly.
* @author: Shalini
* @param exception that occur in the program.
* @returns error page
* Date :19-10-2005
--%>
<%--
* import statements required for this jsp page.
--%>
<%@ page import="project.InvalidCustomer" %>
<%@ page import="project.InvalidAccount" %>
<%@ page import="project.InvalidAmount" %>
<%@ page import="project.InsufficientBalance" %>
<%@ page import="project.ClosedAccountException" %>
<%@ page isErrorPage = "true" %>
<%@ page session="true" %>
<% String s=session.getId();
Integer isValid=(Integer)session.getAttribute("Valid");
Integer count=(Integer)session.getAttribute("Count");
Integer previous=(Integer)session.getAttribute("Prev");
if(isValid!=null)
{
isValid=new Integer(previous.intValue());
session.setAttribute("Valid",isValid);
%>
<html>
<head>
<title>Infy Bank - Error</title>
<link rel="stylesheet" type="text/css" href="commonstyle.css">
<table cellpadding="10" cellspacing="3" align="center">
<tr>
<td><img src=
"C:\Documents and Settings\sarath_g\Desktop\logo.jpg"/>
</tr>
</table>
</head>
<body>
<center>
<%
String errorMessage = exception.toString();
String errorName="";
int colIndex = errorMessage.indexOf(':');
if (colIndex == -1)
errorName=errorMessage;
else
errorName = errorMessage.substring(0,colIndex);
if(errorName.equals("java.lang.NumberFormatException"))
{%>
<h1>
<font color="red">ERROR!!!</font>
</h1>
<hr>
<table bgcolor="red">
<tr>
<center>
<td colspan="2">
<h2>
<font color="red">Invalid Number Format</font>
</h2>
</td>
</center>
</tr>
</table>
<%}
else if(errorName.equals("project.InvalidCustomer"))
{ %>
<h1><font color="red">ERROR!!!</font></h1>
<hr>
<table bgcolor="red">
<tr>
<center>
<td colspan="2">
<h2>
<font color="red">Invalid Customer ID</font>
</h2>
</td>
</center>
</tr>
</table>
<% }
else if(errorName.equals("project.InvalidAmount"))
{ %>
<h1>
<font color="red">ERROR!!!</font>
</h1>
<hr>
<table bgcolor="red">
<tr>
<center>
<td colspan="2">
<h2>
<font color="red">Invalid Amount</font>
</h2>
</td>
</center>
</tr>
</table>
<% }
else if(errorName.equals("project.InsufficientBalance"))
{%>
<h1>
<font color="red">ERROR!!!</font>
</h1>
<hr>
<table bgcolor="red">
<tr>
<center>
<td colspan="2">
<h2>
<font color="red">Insufficient Balance</font>
</h2>
</td>
</center>
</tr>
</table>
<% }
else if(errorName.equals("project.InvalidAccount"))
{ %>
<h1>
<font color="red">ERROR!!!</font>
</h1>
<hr>
<table bgcolor="red">
<tr>
<center>
<td colspan="2">
<h2>
<font color="red">No Account exists</font>
</h2>
</td>
</center>
</tr>
</table>
<% }
else if(errorName.equals("project.ClosedAccountException"))
{ %>
<h1>
<font color="red">ERROR!!!</font>
</h1>
<hr>
<table bgcolor="red">
<tr>
<center>
<td colspan="2">
<h2>
<font color="red">
Sorry!!Account has been closed.
Transaction not possible
</font>
</h2>
</td>
</center>
</tr>
</table>
<% }
else if(errorName.equals("java.sql.SQLException"))
{ %>
<h1>
<font color="red">ERROR!!!</font>
</h1>
<hr>
<table bgcolor="red">
<tr>
<center>
<td colspan="2">
<h2>
<font color="red">Invalid data entry..<%=exception.getLocalizedMessage()%></font>
</h2>
</td>
</center>
</tr>
</table>
<% }
else if(exception.getLocalizedMessage().equals("Infy password policy violation"))
{%>
<h1><font color="red"><marquee>ERROR!!!</marquee></font></h1>
<hr>
<table bgcolor="red">
<tr>
<center>
<td colspan="2">
<h2>
<font color="red">
<%out.print("Infy Bank Password Policy violated.Your new password");%>
<%out.print("should contain atleast 8 characters and also it");%>
<%out.print("should contain atleast 3 of following 4 groups:");%>
<%out.print("1.English Upper Case Characters(A - Z)");%>
<%out.print("2.English Lower Case Characters(a - z)");%>
<%out.print("3.Numerals(0-9)");%>
<%out.print("4.Special characters(#,@,!..etc).");%>
</font>
</h2>
</td>
</center>
</tr>
</table>
<%}
else if(exception.getLocalizedMessage().equals("Confirmation required"))
{%>
<h1><font color="red"><marquee>ERROR!!!</marquee></font></h1>
<hr>
<table bgcolor="red">
<tr>
<center>
<td colspan="2">
<h2>
<font color="red">
<%out.print(" The passwords given doesn't match.");%>
</font>
</h2>
</td>
</tr>
<tr>
<td>
<h2>
<font color="red">
<%out.print("Please fill new password in both the fields");%>
</font>
</h2>
</td>
</center>
</tr>
</table>
<%}
else if(exception.getLocalizedMessage().equals("Wrong password"))
{%>
<h1><font color="red"><marquee>ERROR!!!</marquee></font></h1>
<hr>
<table bgcolor="red">
<tr>
<center>
<td colspan="2">
<h2>
<font color="red">
<%out.print("your username or oldpassword is not correct.");%>
<%out.print("password field must be typed in correct case.");%>
</font>
</h2>
</td>
</center>
</tr>
</table>
<%}
else
{%>
<h1><font color="red">ERROR!!!</font></h1>
<hr>
<table bgcolor="red">
<tr>
<center>
<td colspan="2">
<h2>
<font color="red">
<%out.print(exception.getLocalizedMessage());%>
</font>
</h2>
</td>
</center>
</tr>
</table>
<% } %>
<input type="button" name="back" value="Back" onclick="history.go(-1)">
</center>
</body>
</html>
<%}%>
It gives the error that the package project doesn't exist.I have all my jsp files ,java files and the proj.jar file in the C:\project folder and i have included my proj.jar in the classpath.
my server.xml file includes
<Context path="/bank" docBase="C:\project" debug="0"
reloadable="true" crossContext="true">
if anyone knows how to solve this error plz reply.
Thanks