1 4 5 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 getAttribute(String 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 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 name, HttpServletRequest req) { 54 HttpSession session = req.getSession(); 55 session.removeAttribute(name); 56 } 57 58 public static void setAttribute(String name, String value, HttpServletRequest req) { 59 _setAttribute(name, value, req); 60 } 61 62 public static void setAttribute(String name, int value, HttpServletRequest req) { 63 _setAttribute(name, new Integer (value), req); 64 } 65 66 public static void setAttribute(String name, double value, HttpServletRequest req) { 67 _setAttribute(name, new Double (value), req); 68 } 69 70 public static void setAttribute(String name, float value, HttpServletRequest req) { 71 _setAttribute(name, new Float (value), req); 72 } 73 74 75 public static void setAttribute(String name, Vector value, HttpServletRequest req) { 76 _setAttribute(name, value, req); 77 } 78 79 80 public static void setAttribute(String name, Hashtable value, HttpServletRequest req) { 81 _setAttribute(name, value, req); 82 } 83 84 static void _setAttribute(String name, Object 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 |