File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getHeaders and getRequestDispatcher

 
Salima Lalani
Ranch Hand
Posts: 59
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 260
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dharmin Desai
Ranch Hand
Posts: 81
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic