Cant read the header info
Hi all
Am not able to read the header info from my servlet .
In JSP
response.setHeader("UNIVERSALID","nave");
RequestDispatcher view = request.getRequestDispatcher("Login");
view.forward(request,response);
In Login Servlet
-
request.getHeader("UNIVERSALID") is resulting null
How to get the header am setting in JSP . Please help
# 2
For sendredirect the work will be done on the browser end whereas for request dispatcher i t wil be done on teh server end.
Please can u expain me how is ti related to my question
# 3
No.
The RequestDispatcher#forward() forwards the request to the given resource (which reuses the request and ignores the response).
The HttpServletResponse#sendRedirect() redirects the response to the given resource (which creates a new request based on the response).
# 4
Thanks fro that explnation Balu. But i tried using
response.sendRedirect("Login");
This Login is a servlet but even then am not able to get it .
# 6
I overlooked that the adding/reading headers aren't going to work in a HTTP 302 response.
Use HttpServletRequest#setAttribute() to set the value, forward the request with RequestDispatcher#forward() and then use HttpServletRequest#getAttribute() to get the value.