• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

servlets

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
guys, we can forward request using request's or context's requestDispatcher.In which case we will use request, and in which case we will use context? also whats the difference between / and ../. Please help
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First, a few things that will help you out here on the Ranch.

Please be sure to take the time to compose descriptive subjects for your posts; read this for more information.

Using a title of "servlets" in a forum completely dedicated to questions on Servlets isn't very helpful.

Please go back and change your post to add a more meaningful subject by clicking the

Secondly, not everyone who helps people out here is a "guy".
 
Ranch Hand
Posts: 30
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Krishna,

We can forward a request either by using the RequestDispatcher() of ServletContext interface or the ServletRequest interface, the point when to use ServletContext or ServletRequest is that the ServletRequest looks for the resources in the same context (same webapp) to which the invoking servlet belongs.

Moreover the pathname used in the RequestDispatcher() of ServletContext must begin with a "/" which is an absolute path.

The pathname used in the RequestDispatcher() of ServletRequest interface can be an absolute path or a relative path means it can start with “/” or “../..”.
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That kind of questions are usually answered in the API docs.

http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContext.html#getRequestDispatcher(java.lang.String)
http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#getRequestDispatcher(java.lang.String)

Please familiarize yourself with the API docs and learn to find/understand them.

Edit: links fixed, UBB parser didn´t seem to take the last parenthesis in the generated URL.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic