01: /*
02: * @(#)requestScope.java 1.2 04/12/06
03: *
04: * Copyright (c) 1997-2004 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * See the file "LICENSE.txt" for information on usage and redistribution
07: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
08: */
09: package org.pnuts.servlet;
10:
11: import pnuts.servlet.*;
12: import pnuts.lang.Context;
13: import pnuts.lang.PnutsFunction;
14: import pnuts.lang.Package;
15: import javax.servlet.*;
16: import javax.servlet.http.*;
17:
18: /*
19: * function requestScope()
20: */
21: public class requestScope extends PnutsFunction {
22: public requestScope() {
23: super ("requestScope");
24: }
25:
26: public boolean defined(int nargs) {
27: return (nargs == 0);
28: }
29:
30: protected Object exec(Object args[], Context context) {
31: if (args.length != 0) {
32: undefined(args, context);
33: return null;
34: }
35: Package requestPackage = (Package) context
36: .get(PnutsServlet.REQUEST_SCOPE);
37: if (requestPackage == null) {
38: throw new IllegalStateException();
39: }
40: return requestPackage;
41: }
42:
43: public String toString() {
44: return "function requestScope()";
45: }
46: }
|