Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

NullPointerException with RequestDispatcher

843841Jul 26 2007 — edited Jul 8 2008
Hi all,

I'm developing a login servlet but have a recurring problem with the RequestDispatcher throwing up a NullPointerException. I call the RequestDispatcher using this method:
RequestDispatcher dispatcher = null;
		
if (dbpass.equals(password))
{
	session = request.getSession(true);
	session.setAttribute("user",uID);
	session.setAttribute("dept",uDept);
	dispatcher = getServletContext().getRequestDispatcher("/index.html");
}
else
{
	dispatcher = getServletContext().getRequestDispatcher("/loginjsp.jsp");
}
dispatcher.forward(request, response);
The layout of the directory is:

WEBAPP
---- index.html
---- loginjsp.jsp
|
----WEB-INF

The servlet is mapped as though it were in the root webapp directory. What I've read on here suggests to me the problem lies in the path I'm giving the RequestDispatcher, but I've tried almost all the other possible paths I can think of and still get the exception error.

Any thoughts would be appreciated!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 5 2008
Added on Jul 26 2007
12 comments
5,067 views