Project

General

Profile

« Previous | Next » 

Revision 1723

Added by berkley almost 21 years ago

got interservlet session handling working.

View differences:

MetaCatServlet.java
118 118
  private PropertyResourceBundle options = null;
119 119
  private MetaCatUtil util = null;
120 120
  private DBConnectionPool connPool = null;
121
  private Hashtable sessionHash = new Hashtable();
121 122
  private static final String PROLOG = "<?xml version=\"1.0\"?>";
122 123
  private static final String SUCCESS = "<success>";
123 124
  private static final String SUCCESSCLOSE = "</success>";
......
292 293
        out.close();
293 294

  
294 295
      // aware of session expiration on every request
295
      } else {
296

  
296
      }
297
      else
298
      {
297 299
        HttpSession sess = request.getSession(true);
298
        if (sess.isNew()) {
300
        if (sess.isNew() && !params.containsKey("sessionid")) {
299 301
          // session expired or has not been stored b/w user requests
300 302
          username = "public";
301 303
          sess.setAttribute("username", username);
302
        } else {
303
          username = (String)sess.getAttribute("username");
304
          password = (String)sess.getAttribute("password");
305
          groupnames = (String[])sess.getAttribute("groupnames");
306
          try {
304
        }
305
        else
306
        {
307
          try
308
          {
307 309
            if(params.containsKey("sessionid"))
308 310
            {
309
              sess_id = (String)params.get("sessionid");
310
              sess.setAttribute("JSESSIONID", sess_id);
311
              sess_id = ((String[])params.get("sessionid"))[0];
312
              if(sessionHash.containsKey(sess_id))
313
              {
314
                sess = (HttpSession)sessionHash.get(sess_id);
315
              }
311 316
            }
312 317
            else
313 318
            {
314 319
              sess_id = (String)sess.getId();
320
              sessionHash.put(sess_id, sess);
315 321
            }
316
          } catch(IllegalStateException ise) {
322
          }
323
          catch(IllegalStateException ise)
324
          {
317 325
            System.out.println("error in handleGetOrPost: this shouldn't " +
318 326
                               "happen: the session should be valid: " +
319 327
                               ise.getMessage());
320 328
          }
329

  
330
          username = (String)sess.getAttribute("username");
331
          password = (String)sess.getAttribute("password");
332
          groupnames = (String[])sess.getAttribute("groupnames");
321 333
        }
322 334
      }
323 335

  

Also available in: Unified diff