tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Abe Weintraub <>
Subject retaining HttpSession when using xtags
Date Fri, 18 Jul 2003 21:43:57 GMT

I am working on an web app that is running under tomcat 4.1.17 and using
taglibs xtags, and was hoping to get some help for a problem we are

The problem is that a new HttpSession is being created for each call to
the Servlet and we don't want it to be.  The problem seems to be in how
the xtags:style tag is communicating with the Servlet (not forwarding
the request?).

The Servlet creates a new Session every time the test.jsp contacts it
via the xtag.  This problem does not occur when accessing the servlet
directly without going through the test.jsp.

Is there any way to forward the request and session to the Servlet and
back to the JSP and still use the xtags:style?
We would rather not have to refactor the entire app, and we realize it
is lame to have the servlet manually create the XML as a String.


Here is the JSP code that uses the xtags.

<!-- test.jsp -->

String xsl = "xsl/test.xsl";
xml =

<%=session.getId() %>

    xml="<%= xml %>"
    xsl="<%= xsl %>" />


// Now here is the relevant Servlet code that creates a valid XML
response as a String

protected doPost (HttpServletRequest req , HttpServletResponse rsp) {

   HttpSession loSession   = req.getSession(true);
   loSession.setAttribute("listener", this);

   log.debug("Your session id is: " + loSession.getId());

   if(loSession.isNew()) {
      log.debug("new session");
   } else {
      log.debug("old session");
   String lsXml = this.someStuffThatCreatesXML();

   try {
     PrintWriter out = rsp.getWriter() ;
     out.println(lsXml) ;

  } catch(IOException e) {
     log.error ("Error exporting XML: "+e+".") ;

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message