I have read the following warning in several books that for setHeader, need
to:
"Be sure to set response headers before sending any document content to
the client."

Eg. of such a warning - see page 144 of:
http://developer.java.sun.com/developer/Books/cservletsjsp/chapter7.pdf

There is a sample of do proper setHeader for Servlets (see page 156, 157 in
the above PDF).

Basically the setHeader command is placed BEFORE the PrinWriter command.
ie.
response.setHeader("Refresh", "5");
response.setContentType("text/html");
PrintWriter out = response.getWriter();

How can I achieve this in JSP?
I have tried using
<% response.setHeader("Refresh", "5"); %>
<HTML>
  ....

but I find that the generated servlet code is as follows:
out = pageContext.getOut();
out.print(_jspx_html_data[0]);
response.setHeader("Cache-Control", "no-cache");

ie. the setHeader comes AFTER some print commands.

Is this acceptable? or is there something wrong with the way I am coding my
setHeader in the JSP?

[I know that in the case of setContentType, there is a special command
<%@ page contentType="...." %> to ensure that the setContentType command is
generated in the correct position - ie. before any out.print command.
Is there something equivalent for setHeader?]

Thanks.

===========================================================================
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