home *** CD-ROM | disk | FTP | other *** search
- package javax.servlet.jsp;
-
- import java.io.IOException;
- import java.util.Enumeration;
- import java.util.Hashtable;
- import javax.servlet.Servlet;
- import javax.servlet.ServletConfig;
- import javax.servlet.ServletContext;
- import javax.servlet.ServletException;
- import javax.servlet.ServletRequest;
- import javax.servlet.ServletResponse;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpSession;
-
- public abstract class PageContext {
- public static final int PAGE_SCOPE = 1;
- public static final int REQUEST_SCOPE = 2;
- public static final int SESSION_SCOPE = 3;
- public static final int APPLICATION_SCOPE = 4;
- public static final String PAGE = "javax.servlet.jsp.jspPage";
- public static final String PAGECONTEXT = "javax.servlet.jsp.jspPageContext";
- public static final String REQUEST = "javax.servlet.jsp.jspRequest";
- public static final String RESPONSE = "javax.servlet.jsp.jspResponse";
- public static final String CONFIG = "javax.servlet.jsp.jspConfig";
- public static final String SESSION = "javax.servlet.jsp.jspSession";
- public static final String OUT = "javax.servlet.jsp.jspOut";
- public static final String APPCONTEXT = "javax.servlet.jsp.jspAppContext";
- public static final String EXCEPTION = "javax.servlet.jsp.jspException";
- protected Servlet servlet;
- protected ServletConfig config;
- protected ServletContext context;
- protected JspFactory factory;
- protected boolean needsSession;
- protected String errorPageURL;
- protected boolean autoFlush;
- protected int bufferSize;
- protected transient Hashtable attributes = new Hashtable(16);
- protected transient ServletRequest request;
- protected transient ServletResponse response;
- protected transient HttpSession session;
- protected transient JspWriter out;
-
- protected PageContext(JspFactory var1) {
- this.factory = var1;
- }
-
- public void initialize(Servlet var1, ServletRequest var2, ServletResponse var3, String var4, boolean var5, int var6, boolean var7) throws IOException, IllegalStateException, IllegalArgumentException {
- this.servlet = var1;
- this.config = var1.getServletConfig();
- this.context = this.config.getServletContext();
- this.needsSession = var5;
- this.errorPageURL = var4;
- this.bufferSize = var6;
- this.autoFlush = var7;
- this.request = var2;
- this.response = var3;
- if (var2 instanceof HttpServletRequest) {
- this.session = ((HttpServletRequest)var2).getSession(var5);
- }
-
- if (var5 && this.session == null) {
- throw new IllegalStateException("Page needs a session and none is available");
- } else {
- this.out = this._createOut(var6, var7);
- if (this.out == null) {
- throw new IllegalStateException("failed initialize JspWriter");
- } else {
- this.setAttribute("javax.servlet.jsp.jspOut", this.out);
- this.setAttribute("javax.servlet.jsp.jspRequest", var2);
- this.setAttribute("javax.servlet.jsp.jspResponse", var3);
- if (this.session != null) {
- this.setAttribute("javax.servlet.jsp.jspSession", this.session);
- }
-
- this.setAttribute("javax.servlet.jsp.jspPage", var1);
- this.setAttribute("javax.servlet.jsp.jspConfig", this.config);
- this.setAttribute("javax.servlet.jsp.jspPageContext", this);
- this.setAttribute("javax.servlet.jsp.jspAppContext", this.context);
- }
- }
- }
-
- public void release() {
- this.servlet = null;
- this.config = null;
- this.context = null;
- this.needsSession = false;
- this.errorPageURL = null;
- this.bufferSize = -1;
- this.autoFlush = true;
- this.request = null;
- this.response = null;
- this.out = null;
- this.session = null;
- this.attributes.clear();
- }
-
- public Object getAttribute(String var1) {
- return this.attributes.get(var1);
- }
-
- public Object getAttributeWithScope(String var1, int var2) {
- switch (var2) {
- case 1:
- return this.attributes.get(var1);
- case 2:
- return this.request.getAttribute(var1);
- case 3:
- if (this.session == null) {
- throw new IllegalArgumentException("can't access SESSION_SCOPE without an HttpSession");
- }
-
- return this.session.getValue(var1);
- case 4:
- return this.context.getAttribute(var1);
- default:
- throw new IllegalArgumentException("unidentified scope");
- }
- }
-
- public void setAttribute(String var1, Object var2) {
- this.attributes.put(var1, var2);
- }
-
- public void setAttributeInScope(String var1, Object var2, int var3) {
- switch (var3) {
- case 1:
- this.attributes.put(var1, var2);
- return;
- case 2:
- this.request.setAttribute(var1, var2);
- return;
- case 3:
- if (this.session == null) {
- throw new IllegalArgumentException("can't access SESSION_SCOPE without an HttpSession");
- }
-
- this.session.putValue(var1, var2);
- return;
- case 4:
- this.context.setAttribute(var1, var2);
- return;
- default:
- }
- }
-
- public void removeAttribute(String var1) {
- this.attributes.remove(var1);
- }
-
- public void removeAttributeInScope(String var1, int var2) {
- switch (var2) {
- case 1:
- this.attributes.remove(var1);
- return;
- case 2:
- throw new IllegalArgumentException("cant remove Attributes from request scope");
- case 3:
- if (this.session == null) {
- throw new IllegalArgumentException("can't access SESSION_SCOPE without an HttpSession");
- }
-
- this.session.removeValue(var1);
- return;
- case 4:
- this.context.removeAttribute(var1);
- return;
- default:
- }
- }
-
- public int getAttributesScope(String var1) {
- if (this.attributes.get(var1) != null) {
- return 1;
- } else if (this.request.getAttribute(var1) != null) {
- return 2;
- } else if (this.session != null && this.session.getValue(var1) != null) {
- return 3;
- } else {
- return this.context.getAttribute(var1) != null ? 4 : 0;
- }
- }
-
- public Enumeration getAttributeNamesInScope(int var1) {
- switch (var1) {
- case 1:
- return this.attributes.keys();
- case 2:
- return this.request.getAttributeNames();
- case 3:
- if (this.session != null) {
- return new _StringArrayEnum(this.session.getValueNames());
- }
-
- throw new IllegalArgumentException("can't access SESSION_SCOPE without an HttpSession");
- case 4:
- return this.context.getAttributeNames();
- default:
- return new 1();
- }
- }
-
- public JspWriter getOut() {
- return this.out;
- }
-
- public HttpSession getSession() {
- return this.session;
- }
-
- public Servlet getServlet() {
- return this.servlet;
- }
-
- public ServletConfig getServletConfig() {
- return this.config;
- }
-
- public ServletContext getServletContext() {
- return this.config.getServletContext();
- }
-
- public ServletRequest getServletRequest() {
- return this.request;
- }
-
- public ServletResponse getServletResponse() {
- return this.response;
- }
-
- public Exception getException() {
- return (Exception)this.request.getAttribute("javax.servlet.jsp.jspException");
- }
-
- public abstract void forward(String var1) throws ServletException, IOException;
-
- public abstract void include(String var1, JspWriter var2) throws ServletException, IOException;
-
- public abstract void handlePageException(Exception var1);
-
- protected abstract JspWriter _createOut(int var1, boolean var2) throws IOException, IllegalArgumentException;
- }
-