• 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:

Doubt regarding forward method in request dispatcher

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I was going through Mikalai Zaikin notes and came across the following lines about forward method in request dipatcher..can anyone please explain???

"The path elements of the request object exposed to the target servlet must reflect the path used to
obtain the RequestDispatcher. The only exception to this is if the RequestDispatcher was obtained
via the getNamedDispatcher method. In this case, the path elements of the request object must reflect
those of the original request. Before the forward method of the RequestDispatcher interface returns,
the response content MUST be sent and committed, and closed by the servlet container. "
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here the author is talking about the ServletContext and RequestDispatcher methods.
**The path elements of the request object exposed to the target servlet must reflect the path used to
obtain the RequestDispatcher.
--> public RequestDispatcher getRequestDispatcher(java.lang.String path) - path is the location for a resource. The pathname must begin with a "/" and is interpreted as relative to the current context root

** The only exception to this is if the RequestDispatcher was obtained
via the getNamedDispatcher method. In this case, the path elements of the request object must reflect
those of the original request.
--> public RequestDispatcher getNamedDispatcher(java.lang.String name) - name is a servlet or JSP name given via server administration or via a web application deployment descriptor
As you see , since the path is not specified, it must reflect those of the original request.

**Before the forward method of the RequestDispatcher interface returns,
the response content MUST be sent and committed, and closed by the servlet container.
-->After you get a dispatcher, considering that you are going to make a call to forward, after you forward, the resource is going
send a response and commit it in the end, and then returns.

Is it clear now?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic