aspose file tools*
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "RequestDispathcher" Watch "RequestDispathcher" New topic
Author

RequestDispathcher

vinay bedidha
Greenhorn

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");
rd.forward(request,response);
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");
rd.forward(request,response);
dont use servlet context.
Thanks
Deepak

------------------
Be Truthful to yourself!


Be Truthful to yourself!
Sreenivasa Majji
Ranch Hand

Joined: Jul 12, 2001
Posts: 224
hi,
Normally I use this approach
RequestDispatcher rd=getServletContext().getRequestDispathcher("/xxx.jsp");
Using
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
Rancher

Joined: Mar 06, 2001
Posts: 13459

(this thread appears to be continued here)
 
jQuery in Action, 2nd edition
 
subject: RequestDispathcher