"jfrederic.clere(a)jboss.com" wrote : The cookies in the included JSP pages are
ignored.
You're right. I see that under the JSP spec description for the include directive:
http://sdlc-esd.sun.com/ESD24/JSCDL/jsp/2.1-fr/jsp-2_1-fr-spec.pdf?AuthPa...
anonymous wrote : An included page cannot change the response status code or set headers.
This precludes invoking methods like setCookie.
| Attempts to invoke these methods will be ignored.
| The constraint is equivalent to the one imposed on the include method of the
RequestDispatcher class.
The workaround seems to be to have the base jsp file create the cookies.
But doing that also seems to fail. Flipping around the example files I used above, the
following also fails to create the cookie. Just including the file seemed to cause it to
fail to create the cookie.
jsptest.jsp
<%@ page contentType="text/html" %>
|
| <jsp:include page="./cookietest.jsp" flush="true"/>
|
| <jsp:directive.page import="javax.servlet.http.Cookie"/>
| <jsp:scriptlet><![CDATA[
| Cookie c = new Cookie("NewCookie","Data for Cooki");
| out.println(c.getName()+": "+c.getValue()+"<br/>");
| response.addCookie(c);
| ]]></jsp:scriptlet>
|
| <html><body>
| <center><b>JSP Test</b></center>
| </body></html>
cookietest.jsp
<%@ page contentType="text/html" %>
| <html><body>
| <p>
| Hello from included page.
| </p>
| </body></html>
After commenting out the include, the cookies show up.
Is this what I should expect? Is there something else that I need to do?
<!-- jsp:include page="./cookietest.jsp" flush="true"/ -->
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4063691#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...