KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openlaszlo > remote > LZHttpSessionRemote


1 /******************************************************************************
2  * LZHttpSessionRemote.java
3  * ****************************************************************************/

4
5 /* J_LZ_COPYRIGHT_BEGIN *******************************************************
6 * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. *
7 * Use is subject to license terms. *
8 * J_LZ_COPYRIGHT_END *********************************************************/

9
10 package org.openlaszlo.remote;
11
12 import java.util.*;
13 import javax.servlet.http.*;
14
15 public class LZHttpSessionRemote
16 {
17     public static Object JavaDoc getAttribute(String JavaDoc name, HttpServletRequest req) {
18         HttpSession session = req.getSession();
19         return session.getAttribute(name);
20     }
21
22     public static Vector getAttributeNames(HttpServletRequest req) {
23         HttpSession session = req.getSession();
24         Vector v = new Vector();
25         Enumeration e = session.getAttributeNames();
26         while (e.hasMoreElements()) {
27             v.add(e.nextElement());
28         }
29         return v;
30     }
31
32
33     public static String JavaDoc getId(HttpServletRequest req) {
34         HttpSession session = req.getSession();
35         return session.getId();
36     }
37
38     public static int getMaxInactiveInterval(HttpServletRequest req) {
39         HttpSession session = req.getSession();
40         return session.getMaxInactiveInterval();
41     }
42
43     public static void invalidate(HttpServletRequest req) {
44         HttpSession session = req.getSession();
45         session.invalidate();
46     }
47
48     public static boolean isNew(HttpServletRequest req) {
49         HttpSession session = req.getSession();
50         return session.isNew();
51     }
52
53     public static void removeAttribute(String JavaDoc name, HttpServletRequest req) {
54         HttpSession session = req.getSession();
55         session.removeAttribute(name);
56     }
57
58     public static void setAttribute(String JavaDoc name, String JavaDoc value, HttpServletRequest req) {
59         _setAttribute(name, value, req);
60     }
61
62     public static void setAttribute(String JavaDoc name, int value, HttpServletRequest req) {
63         _setAttribute(name, new Integer JavaDoc(value), req);
64     }
65
66     public static void setAttribute(String JavaDoc name, double value, HttpServletRequest req) {
67         _setAttribute(name, new Double JavaDoc(value), req);
68     }
69
70     public static void setAttribute(String JavaDoc name, float value, HttpServletRequest req) {
71         _setAttribute(name, new Float JavaDoc(value), req);
72     }
73
74     /** javascript arrays are passed in as Vectors. */
75     public static void setAttribute(String JavaDoc name, Vector value, HttpServletRequest req) {
76         _setAttribute(name, value, req);
77     }
78
79     /** javascript objects are passed in as Hashtables. */
80     public static void setAttribute(String JavaDoc name, Hashtable value, HttpServletRequest req) {
81         _setAttribute(name, value, req);
82     }
83
84     static void _setAttribute(String JavaDoc name, Object JavaDoc value, HttpServletRequest req) {
85         HttpSession session = req.getSession();
86         session.setAttribute(name, value);
87     }
88
89     public static void setMaxInactiveInterval(int interval, HttpServletRequest req) {
90         HttpSession session = req.getSession();
91         session.setMaxInactiveInterval(interval);
92     }
93 }
94
Popular Tags