• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

*****ServletRequest attributes doubt*******

 
Amit Das
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I was reading the Mannings book for SCWCD, Sec 4.8.3 Acessing request-scoped attributes with RequestDispatcher


"One important aspect of the new servlet specification involves he ability of an included or forwarded servlet to access request information through attributes. The name of the attribute dependes on whether
RequestDispatcher.include() or RequestDispatcher.forward() was invoked."


After this a list of Attributes available to included/forwarded servlets for obtainng information about request is given; like Attribute for included servlet are
javax.servlet.include.request_uri, javax.servlet.include.context_path,
javax.servlet.include.servlet_path, javax.servlet.include.path_info and
javax.servlet.include.querry_string
.

Similarly the Attributes for forwarded servlet
are same with include being replaced by forward.

Further the author says.....
"The values corrrespond to the parameters of the original
request, without regard to further forwarding
. For example, if a forwarded servlet invokes req.getServletPath() the result will be the same as if the java.servlet.include.servlet_path attribute had been acquired with
req.getAttribute(?javax.servlet.include.servlet_path?)"


My question is shouldn't this be
"......the result will be the same as if the
java.servlet.forward.servlet_path attribute had been acquired with
req.getAttribute(?javax.servlet.forward.servlet_path?)" ???

Plz clear the doubt, if possible.

Regards,
Amit
 
Amit Das
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If anyone is reading the Mannings book, can they check it out???

Regards,
Amit
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi amit,

if u have HFSJ, u may come accross similar stuff in the mock exam 5 Question 12 (if i m not making a mistake).


you may like to go thru the servlet spec pdf file, page 24 i suppose
it was only a few days back that i read the stuff u r talking about.

if you get some additon in ur knowledge, let me know.

niranjan
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"The values corrrespond to the parameters of the original
request, without regard to further forwarding.

For example, if a forwarded servlet invokes req.getServletPath() the result will be the same as if the java.servlet.include.servlet_path attribute had been acquired with
req.getAttribute(?javax.servlet.include.servlet_path?)"
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"The values corrrespond to the parameters of the original
request, without regard to further forwarding.

For example, if a forwarded servlet invokes req.getServletPath() the result will be the same as if the java.servlet.include.servlet_path attribute had been acquired with
req.getAttribute(?javax.servlet.include.servlet_path?)"

the forwarded in the above sentence is a general term. dont take it to be a forward( ). so the two analogous sentences that you have are -


if a forwarded servlet invokes req.getServletPath() the result will be the same as if the java.servlet.forward.servlet_path attribute had been acquired with
req.getAttribute(?javax.servlet.forward.servlet_path?)"

and


if a forwarded servlet invokes req.getServletPath() the result will be the same as if the java.servlet.include.servlet_path attribute had been acquired with
req.getAttribute(?javax.servlet.include.servlet_path?)"

correct me if i m wrong
 
Amit Das
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Niranjan,

Thanks for replying.....
Well I'm at one with you for whatever u've said, but can u tell me one more thing what do they mean by putting the '?' before and after the req.getAttribute(?javax.servlet.include.servlet_path?) ......

Regards,
Amit
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a typo. It should be double-quotations.
This book is full of typos, watch out
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please take a look @

http://www.javaworld.com/javaworld/jw-03-2003/jw-0328-servlet-p2.html

and tell me
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic