001: /* ****************************************************************************
002: * LZWebAppRemote.java
003: * ****************************************************************************/
004:
005: /* J_LZ_COPYRIGHT_BEGIN *******************************************************
006: * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. *
007: * Use is subject to license terms. *
008: * J_LZ_COPYRIGHT_END *********************************************************/
009:
010: package org.openlaszlo.remote;
011:
012: import java.util.*;
013: import javax.servlet.http.*;
014: import javax.servlet.*;
015:
016: public class LZWebAppRemote {
017: public static Object getAttribute(String name,
018: HttpServletRequest req) {
019: ServletContext context = req.getSession().getServletContext();
020: return context.getAttribute(name);
021: }
022:
023: public static Vector getAttributeNames(HttpServletRequest req) {
024: ServletContext context = req.getSession().getServletContext();
025: Vector v = new Vector();
026: Enumeration e = context.getAttributeNames();
027: while (e.hasMoreElements()) {
028: v.add(e.nextElement());
029: }
030: return v;
031: }
032:
033: public static int getMajorVersion(HttpServletRequest req) {
034: ServletContext context = req.getSession().getServletContext();
035: return context.getMajorVersion();
036: }
037:
038: public static int getMinorVersion(HttpServletRequest req) {
039: ServletContext context = req.getSession().getServletContext();
040: return context.getMinorVersion();
041: }
042:
043: public static String getMimeType(String file, HttpServletRequest req) {
044: ServletContext context = req.getSession().getServletContext();
045: return context.getMimeType(file);
046: }
047:
048: public static String getServerInfo(HttpServletRequest req) {
049: ServletContext context = req.getSession().getServletContext();
050: return context.getServerInfo();
051: }
052:
053: public static String getServletContextName(HttpServletRequest req) {
054: ServletContext context = req.getSession().getServletContext();
055: return context.getServletContextName();
056: }
057:
058: public static void log(String msg, HttpServletRequest req) {
059: ServletContext context = req.getSession().getServletContext();
060: context.log(msg);
061: }
062:
063: public static void removeAttribute(String name,
064: HttpServletRequest req) {
065: ServletContext context = req.getSession().getServletContext();
066: context.removeAttribute(name);
067: }
068:
069: public static void setAttribute(String name, String value,
070: HttpServletRequest req) {
071: _setAttribute(name, value, req);
072: }
073:
074: public static void setAttribute(String name, int value,
075: HttpServletRequest req) {
076: _setAttribute(name, new Integer(value), req);
077: }
078:
079: public static void setAttribute(String name, double value,
080: HttpServletRequest req) {
081: _setAttribute(name, new Double(value), req);
082: }
083:
084: public static void setAttribute(String name, float value,
085: HttpServletRequest req) {
086: _setAttribute(name, new Float(value), req);
087: }
088:
089: public static void setAttribute(String name, Vector value,
090: HttpServletRequest req) {
091: _setAttribute(name, value, req);
092: }
093:
094: public static void setAttribute(String name, Hashtable value,
095: HttpServletRequest req) {
096: _setAttribute(name, value, req);
097: }
098:
099: static void _setAttribute(String name, Object value,
100: HttpServletRequest req) {
101: ServletContext context = req.getSession().getServletContext();
102: context.setAttribute(name, value);
103: }
104: }
|