1 4 5 9 10 package org.openlaszlo.remote; 11 12 import java.util.*; 13 import javax.servlet.http.*; 14 import javax.servlet.*; 15 16 public class LZWebAppRemote 17 { 18 public static Object getAttribute(String name, HttpServletRequest req) { 19 ServletContext context = req.getSession().getServletContext(); 20 return context.getAttribute(name); 21 } 22 23 public static Vector getAttributeNames(HttpServletRequest req) { 24 ServletContext context = req.getSession().getServletContext(); 25 Vector v = new Vector(); 26 Enumeration e = context.getAttributeNames(); 27 while (e.hasMoreElements()) { 28 v.add(e.nextElement()); 29 } 30 return v; 31 } 32 33 public static int getMajorVersion(HttpServletRequest req) { 34 ServletContext context = req.getSession().getServletContext(); 35 return context.getMajorVersion(); 36 } 37 38 public static int getMinorVersion(HttpServletRequest req) { 39 ServletContext context = req.getSession().getServletContext(); 40 return context.getMinorVersion(); 41 } 42 43 public static String getMimeType(String file, HttpServletRequest req) { 44 ServletContext context = req.getSession().getServletContext(); 45 return context.getMimeType(file); 46 } 47 48 public static String getServerInfo(HttpServletRequest req) { 49 ServletContext context = req.getSession().getServletContext(); 50 return context.getServerInfo(); 51 } 52 53 public static String getServletContextName(HttpServletRequest req) { 54 ServletContext context = req.getSession().getServletContext(); 55 return context.getServletContextName(); 56 } 57 58 public static void log(String msg, HttpServletRequest req) { 59 ServletContext context = req.getSession().getServletContext(); 60 context.log(msg); 61 } 62 63 public static void removeAttribute(String name, HttpServletRequest req) { 64 ServletContext context = req.getSession().getServletContext(); 65 context.removeAttribute(name); 66 } 67 68 public static void setAttribute(String name, String value, HttpServletRequest req) { 69 _setAttribute(name, value, req); 70 } 71 72 public static void setAttribute(String name, int value, HttpServletRequest req) { 73 _setAttribute(name, new Integer (value), req); 74 } 75 76 public static void setAttribute(String name, double value, HttpServletRequest req) { 77 _setAttribute(name, new Double (value), req); 78 } 79 80 public static void setAttribute(String name, float value, HttpServletRequest req) { 81 _setAttribute(name, new Float (value), req); 82 } 83 84 public static void setAttribute(String name, Vector value, HttpServletRequest req) { 85 _setAttribute(name, value, req); 86 } 87 88 public static void setAttribute(String name, Hashtable value, HttpServletRequest req) { 89 _setAttribute(name, value, req); 90 } 91 92 static void _setAttribute(String name, Object value, HttpServletRequest req) { 93 ServletContext context = req.getSession().getServletContext(); 94 context.setAttribute(name, value); 95 } 96 } 97 | Popular Tags |