wood burning stoves
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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 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: http://aspose.com/file-tools
subject: RequestDispathcher
jQuery in Action, 3rd edition