Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • #26289

    We are migrating a JSF web application from Tomcat 6.x onto IBM WebSphere 6.0 which is using pd4ml. Previously we have had no problems with this on Tomcat but now when we try and run our application on WebSphere, there is no HttpSession being passed when we try and render a PDF from a JSP page.

    The basic flow of the app is:

    • a servlet is called which then uses the render( url, os) method
    • The URL points to a JSP page within the same application
    • The OutputStream is the HttpResponse output stream
    • When the page is rendered, it contains a PDF version of the JSP page.

    A basic code snippet of how we have been doing the conversion from the servlet is given below:

    <br /> ...<br /> HttpSession session = request.getSession();<br /> OutputStream output = response.getOutputStream();<br /> PD4ML pd4ml = new PD4ML();<br /> pd4ml.setCookie("JSESSIONID", session.getId());<br /> response.setContentType("application/pdf");<br /> pd4ml.render(new URL(url.toString()), output);<br />

    After this didn’t work initially I tried a few things including:

    • upgrading to the latest version of pd4ml (3.5.1)
    • calling pd4ml.setSessionId(session.getId()) *This never worked originally for some reason
    • appending “;jessionid=” + session.getId() to the end of the URL
    • appending “?pd4session=” + session.getId() to the end of the URL

    Currently the page that gets rendered does not get the HttpSession (so ends up creating a new one) and so values stored in it which are used to populate fields end up displaying as blank.

    Note that I have confirmed that a different session gets created by logging the session id both in the servlet and from the JSP page.

    Could you please advise of any known issues with integration in WebSphere or advise on passing the Session to a rendered page.



    Does it mean

    1. render() cannot load the URL, respecting a given ;jsessionid= or

    2. it loads the main URL correctly, but the session ID is not propagated to the referenced resources (CSS, images etc)?


    The issue is 1. render() cannot load the URL.

    The page is rendered however fields populated by values stored in the jsession are blank.


    Just to confirm above statement:

    The page we are trying to display contained in URL is rendered correctly using the render() method. All CSS, images, HTML etc are rendered correctly as per normal. The jsessionid however is not being transferred to the page used in the render() method.

    This means that where session values are displayed on the page, the value is showing as blank. This is because a new session is created by default in which our attributes used on the page don’t exist.


    Hello PD4ML,
    Could you please provide an email address so that we may contact and deal with your support team directly. This issue is holding up production changes and we can’t afford lengthy delays by waiting on answers to be posted in a forum.

    Previously we had an issue and it was dealt with via email swiftly and attentively. We were hoping it would be a similar case this time. Any knowledge gained outside of the forum can be copied in at a later date.



    The support email address is support at pd4ml dot com. (Sorry for the cryptic email address notation – spam robots are really annoying)


    Was there a resolution to this question?

    I am experiencing the same behavior: when using setSessionID(session.getId()) followed by render() the page that is being rendered has a new session, not the one requested (session.isNew()==true, session.getId() is a new id).


    The session ID propagation of a particular web application depends on the platform and configuration of server or the application.

    In J2EE/Servlet/JSP “world” it uses JSESSIONID cookie or jsessionid URL suffix, however it is possible to override the defaults. Also the configuration may disable the cookie method or the URL suffix method.

    PD4ML supports the following methods of session ID propagation.

    Let’s say we load

    1. pd4ml.setCookie( “JSESSIONID”, cookieValue );

      where cookieValue is something like that: “9034657927465;path=/”

      The cookie is sent with the “main” request to as well as with the requests to the referenced resources (images, CSSs etc)

    2. pd4ml.setSessionID( sessionID )

      In the case PD4ML embeds the sessionID only to referenced resource URLs this way:;jsessionid=9034657927465?other=params&if=any

      If it fails with the embedded jsessionid, it repeats the request without the ID.

      NOTE: It does not embed jsessionid to the original request to, as you have control over the URL string in your Java code, so you can ebbed it by yourself and avoid possible confusions with the request repeating.

      You may see the modified image URLs on STDOUT or in the server log if you switch the debug mode on:


      The default “jsessionid” keyword can be changed with
      JVM command line parameter.

Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Session not transfered when using pd4ml.render()’ is closed to new replies.