• 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:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
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");
iam getting NullPointerException problem.if i use response.sendRedirect("/Home.jsp"); it's working fine.
what's the problem with RequestDispatcher?
 
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 appears to be a continuation of the thread here)
What configuration are you using, is there a web server in front? sendRedirect() forces the browser to make a re-request for the specified page and hence comes from "the outside world". getRequestDispatcher().XXX() loads and returns the respource from the server within the application context.
Dave.
 
vinay bedidha
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi David,
Thanks for your answer.
iam using Borland Application server and jsdk2.0.when iam using RequestDispatcher, during compilation time it's giving error message as follows..
unable to Resolve symbol RequestDispathcher rd=getServletContext().getRequestDispatcher("/Home.jsp");
plz help me..
thanks
 
author
Posts: 3892
5
Redhat Quarkus Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where is "Home.jsp" located with respect to the root of your war file? That might make a difference.
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There might be a clue in the API

The original problem was that getRequestDispatcher() and request.getRequestDispatcher() seemed to offer different behaviour.

From the API: The difference between this method
[ ie: HttpRequest.getRequestDispatcher(java.lang.String) ]
and ServletContext.getRequestDispatcher(java.lang.String) is that this method can take a relative path.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
getServletContext().getRequestDispatcher("Home.jsp").include(request, response);
getServletContext().getRequestDispatcher("Home.jsp").forward(request, response);
cheers.
 
reply
    Bookmark Topic Watch Topic
  • New Topic