users@glassfish.java.net

Re: JSESSIONID that is passed in url can not be utilized

From: <glassfish_at_javadesktop.org>
Date: Thu, 03 Jun 2010 06:53:14 PDT

Hi, thanks for the reply, this is the function in the ejb bean to generate the URL, but somehow, the sessionid in the url is different from the jsp page.
Are you using glassfish v2? can you let me know your session property setting? or if anything I need to configure in glassfish so the jsessionid will be maintained. Thank you.

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;
      /*
      StringBuffer sb = new StringBuffer();
      InputStream in = new URL(url).openStream();

      try {
        InputStreamReader inR = new InputStreamReader( in );
        BufferedReader buf = new BufferedReader( inR );
        String line;
        while ( ( line = buf.readLine() ) != null ) {
          sb.append(line);
      }
      } finally {
        in.close();
    }
    */
    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=472562