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