KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* ****************************************************************************
2  * LZWebAppRemote.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 import javax.servlet.*;
15
16 public class LZWebAppRemote
17 {
18     public static Object JavaDoc getAttribute(String JavaDoc 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 JavaDoc getMimeType(String JavaDoc file, HttpServletRequest req) {
44         ServletContext context = req.getSession().getServletContext();
45         return context.getMimeType(file);
46     }
47
48     public static String JavaDoc getServerInfo(HttpServletRequest req) {
49         ServletContext context = req.getSession().getServletContext();
50         return context.getServerInfo();
51     }
52
53     public static String JavaDoc getServletContextName(HttpServletRequest req) {
54         ServletContext context = req.getSession().getServletContext();
55         return context.getServletContextName();
56     }
57
58     public static void log(String JavaDoc msg, HttpServletRequest req) {
59         ServletContext context = req.getSession().getServletContext();
60         context.log(msg);
61     }
62
63     public static void removeAttribute(String JavaDoc name, HttpServletRequest req) {
64         ServletContext context = req.getSession().getServletContext();
65         context.removeAttribute(name);
66     }
67
68     public static void setAttribute(String JavaDoc name, String JavaDoc value, HttpServletRequest req) {
69         _setAttribute(name, value, req);
70     }
71
72     public static void setAttribute(String JavaDoc name, int value, HttpServletRequest req) {
73         _setAttribute(name, new Integer JavaDoc(value), req);
74     }
75
76     public static void setAttribute(String JavaDoc name, double value, HttpServletRequest req) {
77         _setAttribute(name, new Double JavaDoc(value), req);
78     }
79
80     public static void setAttribute(String JavaDoc name, float value, HttpServletRequest req) {
81         _setAttribute(name, new Float JavaDoc(value), req);
82     }
83
84     public static void setAttribute(String JavaDoc name, Vector value, HttpServletRequest req) {
85         _setAttribute(name, value, req);
86     }
87
88     public static void setAttribute(String JavaDoc name, Hashtable value, HttpServletRequest req) {
89         _setAttribute(name, value, req);
90     }
91
92     static void _setAttribute(String JavaDoc name, Object JavaDoc value, HttpServletRequest req) {
93         ServletContext context = req.getSession().getServletContext();
94         context.setAttribute(name, value);
95     }
96 }
97
Popular Tags