• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt in servlet specification

 
swapna rao
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm reading servlet specification and got a doubt about the forward and request parameters. It is explained in page 65-66 of servlet specification.
When ever we use include or forward of RequestDispatcher , it sets few attributes in the request.

For example inlcude () sets following is the list of attributes:

javax.servlet.include.request_uri
javax.servlet.include.context_path
javax.servlet.include.servlet_path
javax.servlet.include.path_info
javax.servlet.include.query_string

These attributes are accessible from the included servlet via the getAttribute method on the request object and their values must be equal to the request URI,context path, servlet path, path info, and query string of the included servlet,respectively. If the request is subsequently included, these attributes are replaced
for that include.

For forward () :

javax.servlet.forward.request_uri
javax.servlet.forward.context_path
javax.servlet.forward.servlet_path
javax.servlet.forward.path_info
javax.servlet.forward.query_string

The values of these attributes must be equal to the return values of the
HttpServletRequest methods getRequestURI, getContextPath, getServletPath,
getPathInfo, getQueryString respectively, invoked on the request object passed to the first servlet object in the call chain that received the request from the client.

This means that always attributes related to forward() method returns the original request values where as the attributes related to include returns the values based on the included file(servlet/JSP).

Why is this difference present? I didn't understand it . Please anyone explain me.
 
swapna rao
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anyone please clarify my doubt.
 
swapna rao
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any update on this thread would be great.
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In the forword, you may want to track the request from where it is came from. The forward page forwaod the page to different resource and the contains are on included in the processing of original request.

In the same way , in the include you want to know where the request is actually processed. In this case the contents are included in the output of original resource.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic