File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes RequestDispathcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "RequestDispathcher" Watch "RequestDispathcher" New topic


vinay bedidha

Joined: Oct 04, 2001
Posts: 9
i want to transfer control from a servlet to JspPage("Home.jsp")
iam getting a problem when using
RequestDispatcher rd=getServletContext().getRequestDispathcher("/Home.jsp");
iam getting NullPointerException problem.if i use response.sendRedirect("/Home.jsp"); it's working fine.
what's the problem with RequestDispatcher?
deepak bansal
Ranch Hand

Joined: Feb 25, 2001
Posts: 33
Hi Vinay,
Use the following code
RequestDispatcher rd=request.getRequestDispathcher("/Home.jsp");
dont use servlet context.

Be Truthful to yourself!

Be Truthful to yourself!
Sreenivasa Majji
Ranch Hand

Joined: Jul 12, 2001
Posts: 224
Normally I use this approach
RequestDispatcher rd=getServletContext().getRequestDispathcher("/xxx.jsp");
RequestDispatcher rd=request.getRequestDispathcher("/xxx.jsp"); is better approach??
Thanks for your time,
Sreenivasa Kumar Majji
Sun Certified Java Programmer
SCJP Mock Test

Sreenivasa Majji
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

(this thread appears to be continued here)
I agree. Here's the link:
subject: RequestDispathcher
Similar Threads
Problem with cvs
installing plugin for netscape and mozilla
java 1.5 ( generics and autoboxing) not working in Tomcat 5.5.9.
Cannot access servlet after deploying website on cpanel