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
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.
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.
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