• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

RequestDispathcher

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
(this thread appears to be continued here)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic