Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*
*
* This file incorporates work covered by the following copyright and
* permission notice:
*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.jasper.runtime;
import java.io.IOException;
import java.io.Writer;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.logging.Logger;
import java.util.logging.Level;
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.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspFactory;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.JspApplicationContext;
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.el.ExpressionEvaluator;
import javax.servlet.jsp.el.VariableResolver;
import javax.servlet.jsp.el.ImplicitObjectELResolver;
import javax.servlet.jsp.el.ScopedAttributeELResolver;
import javax.el.ELException;
import javax.el.ELResolver;
import javax.el.ELContext;
import javax.el.BeanELResolver;
import javax.el.ArrayELResolver;
import javax.el.MapELResolver;
import javax.el.ResourceBundleELResolver;
import javax.el.ListELResolver;
import javax.el.CompositeELResolver;
import javax.el.ValueExpression;
import javax.el.FunctionMapper;
import javax.el.MethodExpression;
import javax.el.ExpressionFactory;
import javax.el.StaticFieldELResolver;
import org.apache.jasper.Constants;
import org.apache.jasper.compiler.Localizer;
import org.apache.jasper.security.SecurityUtil;
/**
* Implementation of the PageContext class from the JSP spec.
*
* @author Anil K. Vijendran
* @author Larry Cable
* @author Hans Bergsten
* @author Pierre Delisle
* @author Mark Roth
* @author Jan Luehe
* @author Kin-man Chung
*/
public class PageContextImpl extends PageContext {
// Logger
private static Logger log = Logger.getLogger(PageContextImpl.class.getName());
// per-servlet state
private BodyContentImpl[] outs;
private int depth;
private Servlet servlet;
private ServletConfig config;
private ServletContext context;
private JspFactory factory;
private boolean needsSession;
private String errorPageURL;
private int bufferSize;
private JspApplicationContextImpl jspApplicationContext;
private ELResolver elResolver;
private ELContext elContext;
// page-scope attributes
private HashMap attributes;
private boolean isNametableInitialized;
// per-request state
private ServletRequest request;
private ServletResponse response;
private HttpSession session;
// initial output stream
private JspWriter out;
private JspWriterImpl baseOut;
/*
* Constructor.
*/
PageContextImpl(JspFactory factory) {
this.factory = factory;
this.outs = new BodyContentImpl[0];
this.attributes = new HashMap(16);
this.depth = -1;
}
public void initialize(Servlet servlet,
ServletRequest request,
ServletResponse response,
String errorPageURL,
boolean needsSession,
int bufferSize,
boolean autoFlush) throws IOException {
_initialize(servlet, request, response, errorPageURL, needsSession,
bufferSize, autoFlush);
}
private void _initialize(Servlet servlet,
ServletRequest request,
ServletResponse response,
String errorPageURL,
boolean needsSession,
int bufferSize,
boolean autoFlush) throws IOException {
// initialize state
this.servlet = servlet;
this.config = servlet.getServletConfig();
this.context = config.getServletContext();
this.needsSession = needsSession;
this.errorPageURL = errorPageURL;
this.bufferSize = bufferSize;
this.request = request;
this.response = response;
// Setup session (if required)
if (request instanceof HttpServletRequest && needsSession)
this.session = ((HttpServletRequest)request).getSession();
if (needsSession && session == null)
throw new IllegalStateException
("Page needs a session and none is available");
// initialize the initial out ...
depth = -1;
if (this.baseOut == null) {
this.baseOut = new JspWriterImpl(response, bufferSize, autoFlush);
} else {
this.baseOut.init(response, bufferSize, autoFlush);
}
this.out = baseOut;
this.isNametableInitialized = false;
setAttribute(Constants.FIRST_REQUEST_SEEN, "true", APPLICATION_SCOPE);
}
private void initializePageScopeNameTable() {
isNametableInitialized = true;
// register names/values as per spec
setAttribute(OUT, this.out);
setAttribute(REQUEST, request);
setAttribute(RESPONSE, response);
if (session != null)
setAttribute(SESSION, session);
setAttribute(PAGE, servlet);
setAttribute(CONFIG, config);
setAttribute(PAGECONTEXT, this);
setAttribute(APPLICATION, context);
}
public void release() {
out = baseOut;
try {
// Do not flush the buffer even if we're not included (i.e.
// we are the main page. The servlet will flush it and close
// the stream.
((JspWriterImpl)out).flushBuffer();
} catch (IOException ex) {
log.warning("Internal error flushing the buffer in release()");
}
servlet = null;
config = null;
context = null;
elContext = null;
elResolver = null;
jspApplicationContext = null;
needsSession = false;
errorPageURL = null;
bufferSize = JspWriter.DEFAULT_BUFFER;
request = null;
response = null;
depth = -1;
baseOut.recycle();
session = null;
attributes.clear();
}
public Object getAttribute(final String name) {
if (name == null) {
throw new NullPointerException(
Localizer.getMessage("jsp.error.attribute.null_name"));
}
if (SecurityUtil.isPackageProtectionEnabled()){
return AccessController.doPrivileged(new PrivilegedAction