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: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to