This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes Set and Get the values from the Http Header Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Set and Get the values from the Http Header" Watch "Set and Get the values from the Http Header" New topic
Author

Set and Get the values from the Http Header

Ravindranath Chowdary
Ranch Hand

Joined: Nov 08, 2006
Posts: 71
Hi
I have a requirement to set the values to the http header in one jsp file and get the values from the http header in the other jsp file.
I tried to set the values to the response by using the both ways mentioned as below...
<%
response.setHeader("name", value);
response.addHeader("name", value);

response.sendRedirect("../second.jsp");
%>

i have the following logic to retrieve from the http header...

<%
StringBuffer sb = new StringBuffer();
Enumeration headerNames = request.getHeaderNames();
%>

Here I could not able to get the values set to the http header.

Can any one give an idea how to set and get the values from the http header.

Thanks,
Ravindra.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
This is fundamentally impossible. Response headers are about the response sent back to the client; they have nothing to do with the next request, and won't be included in it.

But since you are using a redirect, you can pass a value in the URL, like


Ping & DNS - my free Android networking tools app
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

This has nothing to do with the SCJP exam.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Set and Get the values from the Http Header
 
Similar Threads
Could not get the connection in struts database application
Problem while Tag lib Up gradation
setting request header
template:insert problem/issue....
SessionAffinityManager setCookie SESN0066E: The response is already committed to the client.