users@glassfish.java.net

Re: How to prevent Glassfish v2 to rewrite urls with jsessionid?

From: <glassfish_at_javadesktop.org>
Date: Mon, 07 Jun 2010 07:40:44 PDT

Hi , I had found the old post and think maybe you can help me.
We are migrating the app from weblogic to glassfish v2. and one of the program fail. After debug, we find that the sessionid which initiated from one jsp, then the same sessionid pass to a function in ejb. In this function, it generate the URL based on the sessionid, but when this URL run, the sessionid change, it create a new sessionid. Please see the code of the function below. Do you have any idea why glassfish did not maintain the sessionid? Thanks.

public boolean sendURLOutStreamByEmail(String[] pageName, String[] fileName, String toEmail, String emailSubject, String sessionId, String baseURL) {
      File[] files = new File[fileName.length];
    String[] fullName = new String[fileName.length];
    String filePrefix = null;

    try{
      String parentDir = getTmpDir();
    for (int i = 0; i < pageName.length; i++) {
        String url = baseURL + pageName[i] +"&JSESSIONID="+sessionId;
   
 
    filePrefix = parentDir;//fundIds[i] ;
    System.out.println("URL is" + url);
    System.out.println("Generating xls...................filePrefix is" + filePrefix);
    fileName[i] = fileName[i] + ".xls";
    fullName[i] = filePrefix + fileName[i];
    System.out.println("file name is" + fileName[i]);
    System.out.println("full name is" + fullName[i]);
    files[i] = new File(fullName[i]);
    System.out.println("file absolute path is "+ files[i].getAbsolutePath());
    BufferedWriter fileout = new BufferedWriter(new FileWriter(files[i]));
    InputStream in = new URL(url).openStream();
    InputStreamReader inR = new InputStreamReader( in );
    BufferedReader buf = new BufferedReader( inR );
    String line;
    while ( ( line = buf.readLine() ) != null ) {
      fileout.write(line);

    }
[Message sent by forum member 'huancon']

http://forums.java.net/jive/thread.jspa?messageID=473153