Meaningless Drivel is fun!*
The moose likes Servlets and the fly likes getHeaders and getRequestDispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "getHeaders and getRequestDispatcher" Watch "getHeaders and getRequestDispatcher" New topic
Author

getHeaders and getRequestDispatcher

Salima Lalani
Ranch Hand

Joined: Aug 15, 2002
Posts: 59
Hi,
I have couple of questions regarding headers of request and getRequestDispatcher.
1. How can we use the headers information? I wud appreciate example.
2. The API mentions that methods in HttpServletRequest with regarding to headers are
- String getHeader(String name)
- Enumeration getHeaders(String name)
- Enumeration getHeaderNames()
But Hanuman't book mentions Enumeration getHeaderValues(String name) instead of getHeaders. Pls let me know which one is correct.
3. Why the getRequestDispatcher method in ServletContext accepts absolute path and that of ServletRequest accepts relative path.
Thanks in Advance
Salima
Asher Tarnopolski
Ranch Hand

Joined: Jul 28, 2001
Posts: 260
1. regarding the usage of headers. find the chapter about headers in this book and read it:
pdf.coreservlets.com
2. there is no getHeaderValues() but there is a getParameterValues() method. the API is the only right source for these questions. ther eis a typo in your book.
3. you should ask those who design java about this. i don't think there is a really good reason.
if someone knows-i'll be glad to learn.


Asher Tarnopolski
SCJP,SCWCD
Dharmin Desai
Ranch Hand

Joined: Feb 28, 2002
Posts: 81
Dear salima,
Ans.1 I don't hv the exact code but,one most used header is "If-Modified-Since" which helps to use cache. e.g.
req.getHeader("If-Modified-Since") will give u the long value in milliseconds, if yr page is not change when it was supplied at last time, then just display yr cached page.
Ans.2 See to page 38 of Hanument book, it is Enumeration getHeaders(). U may hv the older edition of the book.
Ans.3 ServletContext don't hv the method getRealPath() method whereas ServletRequest can convert that relative path to absolute path.
Moreover, This makes sense because servletRequest has a current request path to
evaluate the relative path while ServletContext does not.
Hope this helps, salima
Best Regards, Dharmin
[ January 21, 2003: Message edited by: Dharmin ]

SCJP2 (93%),SCWCD(88%)<br />-------------------------------<br />Never under estimate yr self, just represent yr profile in proper manner.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Dharmin,
Please change your name to be compliant with JavaRanch's naming policy.
Your displayed name should be 2 separate names with more than 1 letter each. We really would prefer that you use your REAL name.
You can change your name: here.
Thanks,
Cindy


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getHeaders and getRequestDispatcher