aspose file tools*
The moose likes JSP and the fly likes org.apache.jasper.JasperException: Unable to load class for JSP exception while navigating to jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "org.apache.jasper.JasperException: Unable to load class for JSP exception while navigating to jsp" Watch "org.apache.jasper.JasperException: Unable to load class for JSP exception while navigating to jsp" New topic
Author

org.apache.jasper.JasperException: Unable to load class for JSP exception while navigating to jsp

Nagendra Shasthri
Ranch Hand

Joined: Nov 12, 2010
Posts: 35

Hi All,

I am new to jsp coding..When navigating from a jsp page to another jsp page I am getting exception

I am using javascript to navigate..I am in login.jsp page and after giving username and password I have to move to authUser.jsp..I have written document.frmIndex.action="authUser.jsp";..

org.apache.jasper.JasperException: Unable to load class for JSP and java.lang.ClassNotFoundException: org.apache.jsp.authUser1_jsp..

I am using apache tomcat 5.5 server..Can anyone help me resolve my problem?I have deadline for submission..


With Regards,
Shastry
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 507

You tell its authUser.jsp, but seeing below line, I think, you are pointing to authUser1.jsp, perhaps you can show us your code here.

org.apache.jasper.JasperException: Unable to load class for JSP and java.lang.ClassNotFoundException: org.apache.jsp.authUser1_jsp..


Regards, Prasad
SCJP 5 (93%)
Nagendra Shasthri
Ranch Hand

Joined: Nov 12, 2010
Posts: 35

@Prasad...filename is authUser1...This is my javascript code in login.jsp to navigate to authUser1.jsp..


function submitMe(){
var userName = document.frmIndex.UserName.value;
var pwd = document.frmIndex.Password.value;
if(userName == "")
{
alert("Enter the User Name");
return false;
}else if(pwd == "")
{
alert("Enter the Password");
return false;
}else

document.frmIndex.method="POST";
document.frmIndex.action="authUser1.jsp";
document.frmIndex.submit();
}
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 507

Can you post the authUser1.jsp here..
Nagendra Shasthri
Ranch Hand

Joined: Nov 12, 2010
Posts: 35

Actually someone has written the code and I am assigned with buf fixing..So I am not understanind the code properly..This is the code written in authUser1.jsp

<%@ include file="conn/dbConn.jsp" %>

<%@ page session="true"%>
<%@ page errorPage="genErrorPage.jsp"%>
<%@ page import="javax.naming.*"%>



<%
boolean bEmployee = false,bConsultant=false;
int iEID=0,iAccess=0,iHR=0;
String sQuery="";
PreparedStatement pstmt;
String sRetVal="",sNickName="",sLocation="",sDivision="";
ResultSet rst;

int iFirstIndex=0,iLastIndex=0,iFirstTilde=0,iLastTilde=0,iDivision=0;
boolean isValid=false;
//out.println("isValid :"+isValid);

try{
//String sUserName =(String)session.getValue("name");
//String sPassword = (String)session.getValue("password");
//String sPassword = request.getParameter("Password");
String sUserName = request.getParameter("UserName");
String sPassword = request.getParameter("Password");
//isValid = authJNDI.isValidUser(sUserName,sPassword);
isValid =isValidUser(sUserName,sPassword);


//isValid=true;

if (isValid){
CallableStatement cstmt = oConnection.prepareCall("begin ?:=fn_authenticate(?,?);end;");
cstmt.registerOutParameter(1,Types.VARCHAR);
cstmt.setString(2,sUserName);
cstmt.setString(3,sPassword);
cstmt.execute();

sRetVal=cstmt.getString(1);
if(sRetVal.equalsIgnoreCase("NOTFOUND")){
response.sendRedirect("genInvalidUser.htm");
}else{

try{
// out.println(sRetVal);
iFirstIndex = sRetVal.indexOf("~");
iLastIndex = sRetVal.lastIndexOf("~");
iFirstTilde = sRetVal.indexOf("^");
iLastTilde = sRetVal.lastIndexOf("^");
iDivision = sRetVal.indexOf("!");

// out.println(" iFirstIndex:"+iFirstIndex);
// out.println(" iLastIndex:"+iLastIndex);
// out.println(" iFirstTilde :"+iFirstTilde );
// out.println(" iLastTilde :"+iLastTilde );
// out.println(" iDivision:"+iDivision);

sNickName = sRetVal.substring(0,iFirstIndex);
iEID = Integer.parseInt(sRetVal.substring(iFirstIndex+1,iLastIndex));
iAccess = Integer.parseInt(sRetVal.substring(iLastIndex+1,iFirstTilde));
sLocation = sRetVal.substring(iFirstTilde+1,iLastTilde);
iHR = Integer.parseInt(sRetVal.substring(iLastTilde+1,iDivision ));
sDivision = sRetVal.substring(iDivision+1,sRetVal.length());

// out.println(" sNickName :"+sNickName );
// out.println(" iEID :"+iEID );
// out.println(" sLocation :"+sLocation );
// out.println(" iAccess :"+iAccess );
// out.println(" HR :"+iHR);
// out.println(" Division :"+sDivision);

session.putValue("EmpId",new Integer(iEID));
session.putValue("NickName",sNickName);
session.putValue("RRF", new Integer(iAccess));
session.putValue("EmpLoc", sLocation);
session.putValue("HR", new Integer(iHR));
session.putValue("EmpDiv", sDivision);
}catch(Exception ee){
out.println(ee.toString());
throw new Exception("Bad Parameters...");
}
}

if(sUserName.equalsIgnoreCase("guest")){
response.sendRedirect("demoframe.jsp");
}else{
response.sendRedirect("newframe.jsp");
}

cstmt.close();
oConnection.close();
}else{
response.sendRedirect("genInvalidUser.htm");
}



}catch(Exception e){
throw new Exception("Authentication Failed "+e.getMessage());
}
%>


and dbConn.jsp is


<%@page import="java.sql.*,javax.util.*,com.microsoft.jdbc.sqlserver.SQLServerDriver" %>
<% //@ page errorPage="ErrorPage.jsp"%>
<%Connection oConnection = null;
try{
//Class.forName("oracle.jdbc.driver.OracleDriver");
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");

oConnection = DriverManager.getConnection("jdbc:sqlserver://192.168.1.109:1433;DatabaseName=KHRMS","sa", "Welcome12");
}
catch(Exception e){
out.println(e.toString());
//throw new Exception("Error Accessing Database: "+e.getMessage());
}
%>
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 507

Looks like a very legacy code, java inside JSP, is discredited 10 years back.
Can you post the full exception trace.. However, its difficult to debug JSP's with Java code inside it.

P:S: Why can't you try to move these Java code into servlet and try refactoring the code..
Nagendra Shasthri
Ranch Hand

Joined: Nov 12, 2010
Posts: 35

This is the exeption I am getting..

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 load class for JSP
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:591)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:137)
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)


root cause

java.lang.ClassNotFoundException: org.apache.jsp.authUser1_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:589)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:137)
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 Apache Tomcat/5.5.11 logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.5.11

My manager wants it to be edited in the same page..So I cant go for servlet...:-(
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 507

Nagendra Shasthri wrote:
My manager wants it to be edited in the same page..So I cant go for servlet...:-(

Did you check with your manager and let him know, how bad it is to have Java inside JSP's in this era.. If yes, and still (s)he tells to be like this, perhaps you can point them here..

However, regarding the problem, did you try restarting the container, also remove inclusion of dbConn.jsp and check, with this you can narrow out whether the problem is in authUser1.jsp or dbConn.jsp..

Also, what happens, when you directly access the authUser1.jsp file?
Nagendra Shasthri
Ranch Hand

Joined: Nov 12, 2010
Posts: 35

Hi I re started the server but stil getting same exception..When I tried to run authUser1.jsp direclty I got this exception..


org.apache.jasper.JasperException: Unable to compile class for JSP

Generated servlet error:
Syntax error on token ";", delete this token

An error occurred at line: 52 in the jsp file: /db.jsp
Generated servlet error:
Syntax error on token ")", delete this token

An error occurred at line: 8 in the jsp file: /authUser1.jsp
Generated servlet error:
Syntax error on token "else", finally expected

Generated servlet error:
Syntax error on token "catch", Identifier expected

Generated servlet error:
out cannot be resolved

Generated servlet error:
_jspx_out cannot be resolved

Generated servlet error:
out cannot be resolved

Generated servlet error:
out cannot be resolved

Generated servlet error:
out cannot be resolved

Generated servlet error:
_jspx_page_context cannot be resolved

Generated servlet error:
_jspx_page_context cannot be resolved

Generated servlet error:
Syntax error on token "finally", { expected

Generated servlet error:
_jspxFactory cannot be resolved

Generated servlet error:
_jspxFactory cannot be resolved

Generated servlet error:
_jspx_page_context cannot be resolved


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:409)
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:293)
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 Apache Tomcat/5.5.11 logs.
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 507

Perhaps you could have got an answer now, its full of syntax errors.. You first correct them.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: org.apache.jasper.JasperException: Unable to load class for JSP exception while navigating to jsp
 
Similar Threads
JSP/Java Bean problem
jasper Exception: unable to compile JSP
jstl in eclipse
irritating behaviour of Tomcat 5
Tomcat Exception