Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RequestDispathcher

 
vinay bedidha
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Sreenivasa Majji
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(this thread appears to be continued here)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic