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

[393 byte] By [BenjaminJavaa] at [2007-11-27 11:02:03]
# 1

First research the difference between RequestDispatcher#forward() and HttpServletResponse#sendRedirect() and note what happens with the request and the response (and therefore with it's headers).

BalusCa at 2007-7-29 12:40:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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

BenjaminJavaa at 2007-7-29 12:40:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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).

BalusCa at 2007-7-29 12:40:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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 .

BenjaminJavaa at 2007-7-29 12:40:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

any help?

BenjaminJavaa at 2007-7-29 12:40:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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.

BalusCa at 2007-7-29 12:40:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...