I found this on the JSP list (and from Servlets.com).
That's pretty much what I suspected but I really need to pass information
thru headers.
Anyone have any ideas on how to do so?
Thanks.
-Tim
Niraj Soni wrote:
>
> i can't get headers in second page set in first page .
> i am using tomact 3.2.2 .
>
> this is my detail problem
> this is first.jsp
> response.setHeader("Cache-Control", "no-cache");
> response.setHeader("Pragma", "no-cache");
> response.setDateHeader("max-age", 0);
> response.setDateHeader("Expires", 0);
>
> this is second.jsp
>
> Enumeration e = request.getHeaderNames();
>
> while(e.hasMoreElements()){
> String ssss = (String) e.nextElement();
> System.out.println("Header is = "+ssss+ " = "+
> request.getHeader(ssss));
>
> }
>
> System.out.println(" Our Header is = "+
> request.getDateHeader("max-age"));
> System.out.println(" Our Header is = "+
> request.getDateHeader("Expires"));
>
> i can't get headers in second.jsp what i set in first.jsp .
> i am using tomact 3.2.2
You're missing the fact that the request and the response
have distinct sets of headers. Here you set *response* headers
in first.jsp and try to read them as *request* headers in
second.jsp. That can't work.
But what are you really trying to do? The response headers
are intended for the browser, in this example to tell the
browser to cache the response. If you just want to pass
information from one JSP page to another, included of
forwarded to, use either request parameters:
<jsp:include page="second.jsp">
<jsp:param name="foo" value="bar" />
</jsp:include>
or put the object you want to pass in the request scope:
<jsp:useBean id="foo" class="com.mycomp.Bar"
scope="request" />
(or use a scriptlet to call request.setAttribute(), but I
recommend staying away from scripting as much as possible).
Hans
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html