File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes IDEs, Version Control and other tools and the fly likes Gettinh Exception in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Gettinh Exception in JSP" Watch "Gettinh Exception in JSP" New topic
Author

Gettinh Exception in JSP

Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
I'm getting following Exceptions in index.jsp? Please any one help me.

Exceptions:
==========

org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 38

35: boolean RECORD_START_PAGE = false;
36: boolean RECORD_END_PAGE = false;*/
37:
38: UserHelper helper = new UserHelper();
39:
40: //List userValues = helper.getuserValues(startID, endID);
41: List userValues = helper.getUsers();


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)


Following is an index.jsp
=========================

<%--
Document : index
Created on : 3 Sep, 2008, 19:03 PM
Author : Jay Shukla
--%>

<%@page import="com.user.*"%>
<%@page import="java.util.List"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>User Application</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<%@ include file="header.jsp" %>

<div id="content">
<div id="colOne">
<%
/*int startID = 1;
int endID = 10;
int prev_startID =1;
int prev_endID = 10;

int USER_RECORD_COUNT = 1000;

boolean RECORD_START_PAGE = false;
boolean RECORD_END_PAGE = false;*/

UserHelper helper = new UserHelper();

//List userValues = helper.getuserValues(startID, endID);
List userValues = helper.getUsers();
/*if(startID == 1){
RECORD_START_PAGE = true;
}
if(endID == USER_RECORD_COUNT){
RECORD_END_PAGE = true;
}

prev_startID = startID-10;
prev_endID = endID-10;

startID = endID + 1;
endID = endID + 10;*/

int userSize = userValues.size();

out.print("<table>");

/*if(RECORD_START_PAGE){
out.print("<tr><td class='NEXT'> </td><td class='NEXT'> </td><td class='NEXT'> </td><td class='NEXT'><a class='RENT' href=\"index.jsp?startid="+startID+"&endid="+endID+"\">Next</a></td></tr>");
}
else if(RECORD_END_PAGE){
out.print("<tr><td class='NEXT'> </td><td class='NEXT'> </td><td class='NEXT'><a class='NEXT' href=\"index.jsp?startid="+prev_startID+"&endid="+prev_endID+"\">Prev</a></td><td class='NEXT'> </td></tr>");
}else{
out.print("<tr><td class='NEXT'> </td><td class='NEXT'> </td><td class='NEXT'><a class='NEXT' href=\"index.jsp?startid="+prev_startID+"&endid="+prev_endID+"\">Prev</a></td><td class='NEXT'><a class='NEXT' href=\"index.jsp?startid="+startID+"&endid="+endID+"\">Next</a></td></tr>");
}*/

out.print("<tr><th>User ID</th><th>Description</th><th>First Name</th><th>Last Name</th></tr>");
for (int i = 0; i < userSize; i++) {
User user = (User) userValues.get(i);
int userID = user.getUserID();
out.print("<tr>");
out.print("<td class='COL2'>" + user.getUserID() + "</td>");
out.print("<td class='COL2'>" + user.getUserName() + "</td>");
out.print("<td class='COL2'>" + user.getFirstName() + "</td>");
out.print("<td class='COL2'>" + user.getLastName() + "</td>");
out.print("</tr>");
}
out.print("</table>");
%>

</div>

</div>
<%@ include file="footer.jsp" %>
</body>
</html>
Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
Following is UserHelper (if required)

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package com.user;

import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
/**
*
* @author Jay Shukla
*/
public class UserHelper {
Session session = null;

public UserHelper() {
this.session = HibernateUtil.getSessionFactory().getCurrentSession();
}

public User getUserByID(int userID){
User user = null;
List userList = null;
try {
org.hibernate.Transaction tx = session.beginTransaction();
Query q = session.createQuery("from user_login as user where user.userID='"+userID+"'");
userList = (List) q.list();
user = (User) userList.get(0);
} catch (Exception e) {
e.printStackTrace();
}
return user;
}

public List getUsers() {
List userList = null;
try {
org.hibernate.Transaction tx = session.beginTransaction();
Query q = session.createQuery("from user_login");
userList = q.list();
} catch (Exception e) {
e.printStackTrace();
}
return userList;
}

public List getuserValues(int startID, int endID) {
List userList = null;
try {
org.hibernate.Transaction tx = session.beginTransaction();
Query q = session.createQuery("from user_login as user where user.userID between " +startID+ " and " +endID+" ");
//Query q = session.createQuery("from Film as film where film.filmID between 1 and 10");
userList = q.list();
} catch (Exception e) {
e.printStackTrace();
}
return userList;
}





}
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the .


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

Is UserHelper in a package other than the default? Is it properly imported into the page?
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

You certainly have some problem with your UserHelper. Since you have posted this same problem in this duplicate thread .

Request to the moderators to close one
[ September 07, 2008: Message edited by: Amit Ghorpade ]

SCJP, SCWCD.
|Asking Good Questions|
Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
Hi bear thanks for your reply!!! Here UserHelper is in the com.user package and in JSP i have imported all the classes from that package so i think that should not be separate import for that class. Anyhow but i have to try that also i'm bit skeptic that will it work out???!!!
Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
Hi bear i tried importing package separately but it didn;t work.

Amit if there is a problem with UserHelper how to replicate that error. as i'm not getting any indication of an error from IDE!!!
Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
However i;m getting following Exception on IDE's console.


java.lang.IllegalArgumentException: Document base C:\Users\Jay Shukla\Documents\NetBeansProjects\chaptr2\build\web does not exist or is not a readable directory
at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:141)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:3957)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4126)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1147)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)



But does it relate to the exception which i'm getting???!!!
Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
Location of my project is as follows:

C:\Users\Jay Shukla\Documents\NetBeansProjects\userApp
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

Originally posted by shuklajayb shukla:
Location of my project is as follows:

C:\Users\Jay Shukla\Documents\NetBeansProjects\userApp


But that location does not match with the "C:\Users\Jay Shukla\Documents\NetBeansProjects\chaptr2\build\web "

Which Netbeans is looking for.Have you deleted or changed the directory recently?


Hope this helps
Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
ya i have deleted chapter 2 from the NetBeans. But i think that does not have any concerns with this project??? Any how can any one please tell me how to resolve this ???
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

But i think that does not have any concerns with this project?

I think that is the only problem and you need to fix it somehow.

Hope this helps
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Gettinh Exception in JSP
 
Similar Threads
Display error message in div tag
Display error when record not found
Exception in JSP
page refresh problem
layout and multibrowser hell