• 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: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. How can we use the headers information? I wud appreciate example.
Header can be used to get meta infos like the time when a resource was edited on server or can be used to command the browser to refresh or to know the date and time in the (hosting) server.
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.
... no they have mentioned the above said methods also pls refer page 40 (Listing example 4.4)

3. Why the getRequestDispatcher method in ServletContext accepts absolute path and that of ServletRequest accepts relative path.
..the reason is a cause the getrquestdispatcher method of servletRequest has the current request path to evalualte the relative path , while the other doesnot have this privileage ..
[ January 20, 2003: Message edited by: vivek sivakumar ]
 
Salima Lalani
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Vivek,
I still didn't get the reason for ServletRequest evaluating the relative path. Wud appreciate your help.
Thanks
Salima
 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
see RequestDispatcher is an interface in javax.servlet package now consider 2 cases that are as follows :
ServletContext
Used for include OR forward a resources
but that will not take a relativepath
for including OR forwarding a request
as context is not aware of paths.
ServletRequest
Used for include OR forward a resources
but that will take a relativepath
for including OR forwarding a request
as ServletRequest is aware of paths where it came from.
I hope that will work
for more discussion i will be on msn wholeday
rishiyagnik1@hotmail.com
i guess that will help u
Rishi
 
vivek sivakumar
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi rishi ur explanation was better and clearer than mine , good work man.
 
She still doesn't approve of my superhero lifestyle. Or this shameless plug:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic