8 Replies Latest reply on Oct 6, 2007 12:47 AM by Joan Horta Tosas

    Cookies lost when included JSP file used

    Dick Weisinger Newbie

      The following file creates a cookie when called alone, but when this file is included in another JSP, the cookie doesn't survive.
      Is this a bug in the JBoss App server, or is there configuration or code that I can use to get it to work?

      cookietest.jsp

      <%@ page contentType="text/html" %>
      <html><body>
      <p>
      <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>
      </p>
      </body></html>


      It fails though when included in this JSP page:

      jsptest.jsp
      <%@ page contentType="text/html" %>
      <jsp:include page="./cookietest.jsp" flush="true"/>
      <html><body>
      <center><b>JSP Test</b></center>
      </body></html>