This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman 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 Building Microservices this week in the Design 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
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
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
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
 
Have you checked out Aspose?
 
subject: Set and Get the values from the Http Header
 
It's not a secret anymore!