Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getHeaders And getRequestDispatcher

 
Salima Lalani
Ranch Hand
Posts: 59
  • 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
 
vivek sivakumar
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Rishi Yagnik
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
hi rishi ur explanation was better and clearer than mine , good work man.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic