• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getHeaders and getRequestDispatcher

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic