Author: markt
Date: Fri Sep 8 21:02:03 2006
New Revision: 441734
URL: http://svn.apache.org/viewvc?view=rev&rev=441734
Log:
Code clean up since I was looking at this file
- unused fields removed
- tabs -> 8 spaces
Modified:
tomcat/jasper/tc5.5.x/src/share/org/apache/jasper/runtime/PageContextImpl.java
Modified:
tomcat/jasper/tc5.5.x/src/share/org/apache/jasper/runtime/PageContextImpl.java
URL:
http://svn.apache.org/viewvc/tomcat/jasper/tc5.5.x/src/share/org/apache/jasper/runtime/PageContextImpl.java?view=diff&rev=441734&r1=441733&r2=441734
==============================================================================
---
tomcat/jasper/tc5.5.x/src/share/org/apache/jasper/runtime/PageContextImpl.java
(original)
+++
tomcat/jasper/tc5.5.x/src/share/org/apache/jasper/runtime/PageContextImpl.java
Fri Sep 8 21:02:03 2006
@@ -69,7 +69,7 @@
// The expression evaluator, for evaluating EL expressions.
private static ExpressionEvaluatorImpl elExprEval
- = new ExpressionEvaluatorImpl(false);
+ = new ExpressionEvaluatorImpl(false);
// The variable resolver, for evaluating EL expressions.
private VariableResolverImpl variableResolver;
@@ -81,19 +81,14 @@
private Servlet servlet;
private ServletConfig config;
private ServletContext context;
- private JspFactory factory;
- private boolean needsSession;
private String errorPageURL;
- private boolean autoFlush;
- private int bufferSize;
// page-scope attributes
- private transient Hashtable attributes;
+ private transient Hashtable attributes;
// per-request state
private transient ServletRequest request;
private transient ServletResponse response;
- private transient Object page;
private transient HttpSession session;
private boolean isIncluded;
@@ -105,49 +100,45 @@
* Constructor.
*/
PageContextImpl(JspFactory factory) {
- this.factory = factory;
- this.variableResolver = new VariableResolverImpl(this);
- this.outs = new BodyContentImpl[0];
- this.attributes = new Hashtable(16);
- this.depth = -1;
+ this.variableResolver = new VariableResolverImpl(this);
+ this.outs = new BodyContentImpl[0];
+ this.attributes = new Hashtable(16);
+ this.depth = -1;
}
public void initialize(Servlet servlet,
- ServletRequest request,
+ ServletRequest request,
ServletResponse response,
- String errorPageURL,
+ String errorPageURL,
boolean needsSession,
- int bufferSize,
+ int bufferSize,
boolean autoFlush) throws IOException {
- _initialize(servlet, request, response, errorPageURL, needsSession,
- bufferSize, autoFlush);
+ _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.autoFlush = autoFlush;
- 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
+ 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.errorPageURL = errorPageURL;
+ 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 ...
@@ -159,30 +150,30 @@
}
this.out = baseOut;
- // 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);
+ // 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);
- isIncluded = request.getAttribute(
- "javax.servlet.include.servlet_path") != null;
+ isIncluded = request.getAttribute(
+ "javax.servlet.include.servlet_path") != null;
}
public void release() {
out = baseOut;
- try {
- if (isIncluded) {
- ((JspWriterImpl)out).flushBuffer();
+ try {
+ if (isIncluded) {
+ ((JspWriterImpl)out).flushBuffer();
// push it into the including jspWriter
- } else {
+ } else {
// Old code:
//out.flush();
// Do not flush the buffer even if we're not included (i.e.
@@ -190,24 +181,21 @@
// the stream.
((JspWriterImpl)out).flushBuffer();
}
- } catch (IOException ex) {
- log.warn("Internal error flushing the buffer in release()");
- }
-
- servlet = null;
- config = null;
- context = null;
- needsSession = false;
- errorPageURL = null;
- bufferSize = JspWriter.DEFAULT_BUFFER;
- autoFlush = true;
- request = null;
- response = null;
+ } catch (IOException ex) {
+ log.warn("Internal error flushing the buffer in release()");
+ }
+
+ servlet = null;
+ config = null;
+ context = null;
+ errorPageURL = null;
+ request = null;
+ response = null;
depth = -1;
- baseOut.recycle();
- session = null;
+ baseOut.recycle();
+ session = null;
- attributes.clear();
+ attributes.clear();
}
public Object getAttribute(final String name) {
@@ -539,7 +527,7 @@
} else {
doRemoveAttribute(name);
}
- }
+ }
private void doRemoveAttribute(String name){
@@ -557,14 +545,14 @@
}
public JspWriter getOut() {
- return out;
+ return out;
}
public HttpSession getSession() { return session; }
public Servlet getServlet() { return servlet; }
public ServletConfig getServletConfig() { return config; }
public ServletContext getServletContext() {
- return config.getServletContext();
+ return config.getServletContext();
}
public ServletRequest getRequest() { return request; }
public ServletResponse getResponse() { return response; }
@@ -598,10 +586,10 @@
String path = relativeUrlPath;
if (!path.startsWith("/")) {
- String uri = (String)
- request.getAttribute("javax.servlet.include.servlet_path");
- if (uri == null)
- uri = ((HttpServletRequest) request).getServletPath();
+ String uri = (String)
+ request.getAttribute("javax.servlet.include.servlet_path");
+ if (uri == null)
+ uri = ((HttpServletRequest) request).getServletPath();
String baseURI = uri.substring(0, uri.lastIndexOf('/'));
path = baseURI+'/'+path;
}
@@ -610,13 +598,13 @@
}
public void include(String relativeUrlPath)
- throws ServletException, IOException {
+ throws ServletException, IOException {
JspRuntimeLibrary.include(request, response, relativeUrlPath, out,
- true);
+ true);
}
public void include(final String relativeUrlPath, final boolean flush)
- throws ServletException, IOException {
+ throws ServletException, IOException {
if (SecurityUtil.isPackageProtectionEnabled()){
try{
AccessController.doPrivileged(new PrivilegedExceptionAction(){
@@ -639,13 +627,13 @@
}
private void doInclude(String relativeUrlPath, boolean flush)
- throws ServletException, IOException {
+ throws ServletException, IOException {
JspRuntimeLibrary.include(request, response, relativeUrlPath, out,
- flush);
+ flush);
}
public VariableResolver getVariableResolver() {
- return this;
+ return this;
}
public void forward(final String relativeUrlPath)
@@ -694,9 +682,6 @@
String includeUri
= (String) request.getAttribute(Constants.INC_SERVLET_PATH);
- final ServletResponse fresponse = response;
- final ServletRequest frequest = request;
-
if (includeUri != null)
request.removeAttribute(Constants.INC_SERVLET_PATH);
try {
@@ -709,7 +694,7 @@
}
public BodyContent pushBody() {
- return (BodyContent) pushBody(null);
+ return (BodyContent) pushBody(null);
}
public JspWriter pushBody(Writer writer) {
@@ -723,12 +708,12 @@
outs = newOuts;
}
- outs[depth].setWriter(writer);
+ outs[depth].setWriter(writer);
out = outs[depth];
- // Update the value of the "out" attribute in the page scope
- // attribute namespace of this PageContext
- setAttribute(OUT, out);
+ // Update the value of the "out" attribute in the page scope
+ // attribute namespace of this PageContext
+ setAttribute(OUT, out);
return outs[depth];
}
@@ -741,9 +726,9 @@
out = baseOut;
}
- // Update the value of the "out" attribute in the page scope
- // attribute namespace of this PageContext
- setAttribute(OUT, out);
+ // Update the value of the "out" attribute in the page scope
+ // attribute namespace of this PageContext
+ setAttribute(OUT, out);
return out;
}
@@ -863,7 +848,7 @@
* VariableResolver interface
*/
public Object resolveVariable(String pName) throws ELException {
- return variableResolver.resolveVariable(pName);
+ return variableResolver.resolveVariable(pName);
}
private static String XmlEscape(String s) {
@@ -876,11 +861,11 @@
} else if (c == '>') {
sb.append(">");
} else if (c == '\'') {
- sb.append("'"); // '
+ sb.append("'"); // '
} else if (c == '&') {
sb.append("&");
} else if (c == '"') {
- sb.append("""); // "
+ sb.append("""); // "
} else {
sb.append(c);
}
@@ -901,44 +886,44 @@
* @return The result of the evaluation
*/
public static Object proprietaryEvaluate(final String expression,
- final Class expectedType,
- final PageContext pageContext,
- final ProtectedFunctionMapper
functionMap,
- final boolean escape)
- throws ELException
+ final Class expectedType,
+ final PageContext pageContext,
+ final ProtectedFunctionMapper
functionMap,
+ final boolean escape)
+ throws ELException
{
- Object retValue;
+ Object retValue;
if (SecurityUtil.isPackageProtectionEnabled()){
try {
retValue = AccessController.doPrivileged(
- new PrivilegedExceptionAction(){
+ new PrivilegedExceptionAction(){
public Object run() throws Exception{
return elExprEval.evaluate(expression,
- expectedType,
-
pageContext.getVariableResolver(),
- functionMap);
+ expectedType,
+
pageContext.getVariableResolver(),
+ functionMap);
}
});
} catch (PrivilegedActionException ex) {
Exception realEx = ex.getException();
- if (realEx instanceof ELException) {
- throw (ELException) realEx;
- } else {
- throw new ELException(realEx);
- }
- }
- } else {
- retValue = elExprEval.evaluate(expression,
- expectedType,
- pageContext.getVariableResolver(),
- functionMap);
- }
- if (escape) {
- retValue = XmlEscape(retValue.toString());
- }
+ if (realEx instanceof ELException) {
+ throw (ELException) realEx;
+ } else {
+ throw new ELException(realEx);
+ }
+ }
+ } else {
+ retValue = elExprEval.evaluate(expression,
+ expectedType,
+ pageContext.getVariableResolver(),
+ functionMap);
+ }
+ if (escape) {
+ retValue = XmlEscape(retValue.toString());
+ }
- return retValue;
+ return retValue;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]