import java.io.IOException;
+import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
int status = 0;
Integer status_code = (Integer)getRequest().getAttribute(
- "javax.servlet.error.status_code");
+ RequestDispatcher.ERROR_STATUS_CODE);
// Avoid NPE if attribute is not set
if (status_code != null) {
status = status_code.intValue();
}
return new ErrorData(
- (Throwable)getRequest().getAttribute( "javax.servlet.error.exception" ),
+ (Throwable)getRequest().getAttribute(
+ RequestDispatcher.ERROR_EXCEPTION),
status,
- (String)getRequest().getAttribute( "javax.servlet.error.request_uri" ),
- (String)getRequest().getAttribute( "javax.servlet.error.servlet_name" ) );
+ (String)getRequest().getAttribute(
+ RequestDispatcher.ERROR_REQUEST_URI),
+ (String)getRequest().getAttribute(
+ RequestDispatcher.ERROR_SERVLET_NAME)
+ );
}
}
/**
- * The request attribute under which we forward a Java exception
- * (as an object of type Throwable) to an error page.
- */
- public static final String EXCEPTION_ATTR =
- "javax.servlet.error.exception";
-
-
- /**
- * The request attribute under which we forward the request URI
- * (as an object of type String) of the page on which an error occurred.
- */
- public static final String EXCEPTION_PAGE_ATTR =
- "javax.servlet.error.request_uri";
-
-
- /**
- * The request attribute under which we forward a Java exception type
- * (as an object of type Class) to an error page.
- */
- public static final String EXCEPTION_TYPE_ATTR =
- "javax.servlet.error.exception_type";
-
-
- /**
- * The request attribute under which we forward an HTTP status message
- * (as an object of type STring) to an error page.
- */
- public static final String ERROR_MESSAGE_ATTR =
- "javax.servlet.error.message";
-
-
- /**
* The request attribute under which we store the key size being used for
* this SSL connection (as an object of type java.lang.Integer).
*/
/**
- * The request attribute under which the request URI of the included
- * servlet is stored on an included dispatcher request.
- */
- public static final String INCLUDE_REQUEST_URI_ATTR =
- "javax.servlet.include.request_uri";
-
-
- /**
- * The request attribute under which the context path of the included
- * servlet is stored on an included dispatcher request.
- */
- public static final String INCLUDE_CONTEXT_PATH_ATTR =
- "javax.servlet.include.context_path";
-
-
- /**
- * The request attribute under which the path info of the included
- * servlet is stored on an included dispatcher request.
- */
- public static final String INCLUDE_PATH_INFO_ATTR =
- "javax.servlet.include.path_info";
-
-
- /**
- * The request attribute under which the servlet path of the included
- * servlet is stored on an included dispatcher request.
- */
- public static final String INCLUDE_SERVLET_PATH_ATTR =
- "javax.servlet.include.servlet_path";
-
-
- /**
- * The request attribute under which the query string of the included
- * servlet is stored on an included dispatcher request.
- */
- public static final String INCLUDE_QUERY_STRING_ATTR =
- "javax.servlet.include.query_string";
-
-
- /**
- * The request attribute under which the original request URI is stored
- * on an forwarded dispatcher request.
- */
- public static final String FORWARD_REQUEST_URI_ATTR =
- "javax.servlet.forward.request_uri";
-
-
- /**
- * The request attribute under which the original context path is stored
- * on an forwarded dispatcher request.
- */
- public static final String FORWARD_CONTEXT_PATH_ATTR =
- "javax.servlet.forward.context_path";
-
-
- /**
- * The request attribute under which the original path info is stored
- * on an forwarded dispatcher request.
- */
- public static final String FORWARD_PATH_INFO_ATTR =
- "javax.servlet.forward.path_info";
-
-
- /**
- * The request attribute under which the original servlet path is stored
- * on an forwarded dispatcher request.
- */
- public static final String FORWARD_SERVLET_PATH_ATTR =
- "javax.servlet.forward.servlet_path";
-
-
- /**
- * The request attribute under which the original query string is stored
- * on an forwarded dispatcher request.
- */
- public static final String FORWARD_QUERY_STRING_ATTR =
- "javax.servlet.forward.query_string";
-
-
- /**
- * The request attribute under which we forward a servlet name to
- * an error page.
- */
- public static final String SERVLET_NAME_ATTR =
- "javax.servlet.error.servlet_name";
-
-
- /**
* The servlet context attribute under which we store a flag used
* to mark this request as having been processed by the SSIServlet.
* We do this because of the pathInfo mangling happening when using
/**
- * The request attribute under which we forward an HTTP status code
- * (as an object of type Integer) to an error page.
- */
- public static final String STATUS_CODE_ATTR =
- "javax.servlet.error.status_code";
-
-
- /**
* The subject under which the AccessControlContext is running.
*/
public static final String SUBJECT_ATTR =
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
-import org.apache.catalina.Globals;
import org.apache.catalina.Realm;
import org.apache.catalina.Session;
import org.apache.catalina.connector.Request;
ExceptionUtils.handleThrowable(t);
String msg = sm.getString("formAuthenticator.forwardLoginFail");
log.warn(msg, t);
- request.setAttribute(Globals.EXCEPTION_ATTR, t);
+ request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
msg);
}
ExceptionUtils.handleThrowable(t);
String msg = sm.getString("formAuthenticator.forwardErrorFail");
log.warn(msg, t);
- request.setAttribute(Globals.EXCEPTION_ATTR, t);
+ request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
msg);
}
import java.io.UnsupportedEncodingException;
import java.util.EnumSet;
+import javax.servlet.RequestDispatcher;
import javax.servlet.SessionTrackingMode;
import org.apache.catalina.Context;
-import org.apache.catalina.Globals;
import org.apache.catalina.Wrapper;
import org.apache.catalina.comet.CometEvent;
import org.apache.catalina.core.ApplicationSessionCookieConfig;
// Calling the container
connector.getService().getContainer().getPipeline().getFirst().event(request, response, request.getEvent());
- if (!error && !response.isClosed() && (request.getAttribute(Globals.EXCEPTION_ATTR) != null)) {
+ if (!error && !response.isClosed() && (request.getAttribute(
+ RequestDispatcher.ERROR_EXCEPTION) != null)) {
// An unexpected exception occurred while processing the event, so
// error should be called
request.getEvent().setEventType(CometEvent.EventType.ERROR);
success = true;
connector.getService().getContainer().getPipeline().getFirst().invoke(request, response);
Throwable t = (Throwable) request.getAttribute(
- Globals.EXCEPTION_ATTR);
+ RequestDispatcher.ERROR_EXCEPTION);
if (t != null) {
asyncConImpl.setErrorState(t);
}
return (context.getServletContext().getRequestDispatcher(path));
// Convert a request-relative path to a context-relative one
- String servletPath = (String) getAttribute(Globals.INCLUDE_SERVLET_PATH_ATTR);
+ String servletPath = (String) getAttribute(
+ RequestDispatcher.INCLUDE_SERVLET_PATH);
if (servletPath == null)
servletPath = getServletPath();
ExceptionUtils.handleThrowable(t);
context.getLogger().error(sm.getString("coyoteRequest.attributeEvent"), t);
// Error valve will pick this exception up and display it to user
- attributes.put(Globals.EXCEPTION_ATTR, t);
+ attributes.put(RequestDispatcher.ERROR_EXCEPTION, t);
}
}
}
ExceptionUtils.handleThrowable(t);
context.getLogger().error(sm.getString("coyoteRequest.attributeEvent"), t);
// Error valve will pick this exception up and display it to user
- attributes.put( Globals.EXCEPTION_ATTR, t );
+ attributes.put(RequestDispatcher.ERROR_EXCEPTION, t );
}
}
}
(ApplicationHttpRequest) wrapRequest(state);
String contextPath = context.getPath();
HttpServletRequest hrequest = state.hrequest;
- if (hrequest.getAttribute(Globals.FORWARD_REQUEST_URI_ATTR) == null) {
- wrequest.setAttribute(Globals.FORWARD_REQUEST_URI_ATTR,
+ if (hrequest.getAttribute(
+ RequestDispatcher.FORWARD_REQUEST_URI) == null) {
+ wrequest.setAttribute(RequestDispatcher.FORWARD_REQUEST_URI,
hrequest.getRequestURI());
- wrequest.setAttribute(Globals.FORWARD_CONTEXT_PATH_ATTR,
+ wrequest.setAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH,
hrequest.getContextPath());
- wrequest.setAttribute(Globals.FORWARD_SERVLET_PATH_ATTR,
+ wrequest.setAttribute(RequestDispatcher.FORWARD_SERVLET_PATH,
hrequest.getServletPath());
- wrequest.setAttribute(Globals.FORWARD_PATH_INFO_ATTR,
+ wrequest.setAttribute(RequestDispatcher.FORWARD_PATH_INFO,
hrequest.getPathInfo());
- wrequest.setAttribute(Globals.FORWARD_QUERY_STRING_ATTR,
+ wrequest.setAttribute(RequestDispatcher.FORWARD_QUERY_STRING,
hrequest.getQueryString());
}
(ApplicationHttpRequest) wrapRequest(state);
String contextPath = context.getPath();
if (requestURI != null)
- wrequest.setAttribute(Globals.INCLUDE_REQUEST_URI_ATTR,
+ wrequest.setAttribute(RequestDispatcher.INCLUDE_REQUEST_URI,
requestURI);
if (contextPath != null)
- wrequest.setAttribute(Globals.INCLUDE_CONTEXT_PATH_ATTR,
+ wrequest.setAttribute(RequestDispatcher.INCLUDE_CONTEXT_PATH,
contextPath);
if (servletPath != null)
- wrequest.setAttribute(Globals.INCLUDE_SERVLET_PATH_ATTR,
+ wrequest.setAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH,
servletPath);
if (pathInfo != null)
- wrequest.setAttribute(Globals.INCLUDE_PATH_INFO_ATTR,
+ wrequest.setAttribute(RequestDispatcher.INCLUDE_PATH_INFO,
pathInfo);
if (queryString != null) {
- wrequest.setAttribute(Globals.INCLUDE_QUERY_STRING_ATTR,
+ wrequest.setAttribute(RequestDispatcher.INCLUDE_QUERY_STRING,
queryString);
wrequest.setQueryParams(queryString);
}
(state.outerRequest instanceof HttpServletRequest)) {
HttpServletRequest houterRequest =
(HttpServletRequest) state.outerRequest;
- Object contextPath = houterRequest.getAttribute
- (Globals.INCLUDE_CONTEXT_PATH_ATTR);
+ Object contextPath = houterRequest.getAttribute(
+ RequestDispatcher.INCLUDE_CONTEXT_PATH);
if (contextPath == null) {
// Forward
contextPath = houterRequest.getContextPath();
* The set of attribute names that are special for request dispatchers.
*/
protected static final String specials[] =
- { Globals.INCLUDE_REQUEST_URI_ATTR, Globals.INCLUDE_CONTEXT_PATH_ATTR,
- Globals.INCLUDE_SERVLET_PATH_ATTR, Globals.INCLUDE_PATH_INFO_ATTR,
- Globals.INCLUDE_QUERY_STRING_ATTR, Globals.FORWARD_REQUEST_URI_ATTR,
- Globals.FORWARD_CONTEXT_PATH_ATTR, Globals.FORWARD_SERVLET_PATH_ATTR,
- Globals.FORWARD_PATH_INFO_ATTR, Globals.FORWARD_QUERY_STRING_ATTR };
+ { RequestDispatcher.INCLUDE_REQUEST_URI,
+ RequestDispatcher.INCLUDE_CONTEXT_PATH,
+ RequestDispatcher.INCLUDE_SERVLET_PATH,
+ RequestDispatcher.INCLUDE_PATH_INFO,
+ RequestDispatcher.INCLUDE_QUERY_STRING,
+ RequestDispatcher.FORWARD_REQUEST_URI,
+ RequestDispatcher.FORWARD_CONTEXT_PATH,
+ RequestDispatcher.FORWARD_SERVLET_PATH,
+ RequestDispatcher.FORWARD_PATH_INFO,
+ RequestDispatcher.FORWARD_QUERY_STRING };
/**
// Convert a request-relative path to a context-relative one
String servletPath =
- (String) getAttribute(Globals.INCLUDE_SERVLET_PATH_ATTR);
+ (String) getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH);
if (servletPath == null)
servletPath = getServletPath();
import java.util.Enumeration;
import java.util.HashMap;
+import javax.servlet.RequestDispatcher;
import javax.servlet.ServletRequest;
import javax.servlet.ServletRequestWrapper;
-import org.apache.catalina.Globals;
import org.apache.catalina.util.Enumerator;
import org.apache.tomcat.util.res.StringManager;
* The set of attribute names that are special for request dispatchers.
*/
protected static final String specials[] =
- { Globals.INCLUDE_REQUEST_URI_ATTR, Globals.INCLUDE_CONTEXT_PATH_ATTR,
- Globals.INCLUDE_SERVLET_PATH_ATTR, Globals.INCLUDE_PATH_INFO_ATTR,
- Globals.INCLUDE_QUERY_STRING_ATTR, Globals.FORWARD_REQUEST_URI_ATTR,
- Globals.FORWARD_CONTEXT_PATH_ATTR, Globals.FORWARD_SERVLET_PATH_ATTR,
- Globals.FORWARD_PATH_INFO_ATTR, Globals.FORWARD_QUERY_STRING_ATTR };
+ { RequestDispatcher.INCLUDE_REQUEST_URI,
+ RequestDispatcher.INCLUDE_CONTEXT_PATH,
+ RequestDispatcher.INCLUDE_SERVLET_PATH,
+ RequestDispatcher.INCLUDE_PATH_INFO,
+ RequestDispatcher.INCLUDE_QUERY_STRING,
+ RequestDispatcher.FORWARD_REQUEST_URI,
+ RequestDispatcher.FORWARD_CONTEXT_PATH,
+ RequestDispatcher.FORWARD_SERVLET_PATH,
+ RequestDispatcher.FORWARD_PATH_INFO,
+ RequestDispatcher.FORWARD_QUERY_STRING };
// ----------------------------------------------------------- Constructors
import javax.naming.directory.DirContext;
import javax.servlet.DispatcherType;
import javax.servlet.FilterConfig;
+import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext;
getLogger().error(sm.getString(
"standardContext.requestListener.requestInit",
instances[i].getClass().getName()), t);
- request.setAttribute(Globals.EXCEPTION_ATTR,t);
+ request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
return false;
}
}
getLogger().error(sm.getString(
"standardContext.requestListener.requestInit",
instances[j].getClass().getName()), t);
- request.setAttribute(Globals.EXCEPTION_ATTR,t);
+ request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
return false;
}
}
// Error page processing
response.setSuspended(false);
- Throwable t = (Throwable) request.getAttribute(Globals.EXCEPTION_ATTR);
+ Throwable t = (Throwable) request.getAttribute(
+ RequestDispatcher.ERROR_EXCEPTION);
if (t != null) {
throwable(request, response, t);
// Error page processing
response.setSuspended(false);
- Throwable t = (Throwable) request.getAttribute(Globals.EXCEPTION_ATTR);
+ Throwable t = (Throwable) request.getAttribute(
+ RequestDispatcher.ERROR_EXCEPTION);
if (t != null) {
throwable(request, response, t);
errorPage.getLocation());
request.setAttribute(ApplicationFilterFactory.DISPATCHER_TYPE_ATTR,
DispatcherType.ERROR);
- request.setAttribute
- (Globals.STATUS_CODE_ATTR,
- new Integer(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
- request.setAttribute(Globals.ERROR_MESSAGE_ATTR,
+ request.setAttribute(RequestDispatcher.ERROR_STATUS_CODE,
+ new Integer(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
+ request.setAttribute(RequestDispatcher.ERROR_MESSAGE,
throwable.getMessage());
- request.setAttribute(Globals.EXCEPTION_ATTR,
+ request.setAttribute(RequestDispatcher.ERROR_EXCEPTION,
realError);
Wrapper wrapper = request.getWrapper();
if (wrapper != null)
- request.setAttribute(Globals.SERVLET_NAME_ATTR,
+ request.setAttribute(RequestDispatcher.ERROR_SERVLET_NAME,
wrapper.getName());
- request.setAttribute(Globals.EXCEPTION_PAGE_ATTR,
+ request.setAttribute(RequestDispatcher.ERROR_REQUEST_URI,
request.getRequestURI());
- request.setAttribute(Globals.EXCEPTION_TYPE_ATTR,
+ request.setAttribute(RequestDispatcher.ERROR_EXCEPTION_TYPE,
realError.getClass());
if (custom(request, response, errorPage)) {
try {
ErrorPage errorPage = context.findErrorPage(statusCode);
if (errorPage != null) {
response.setAppCommitted(false);
- request.setAttribute(Globals.STATUS_CODE_ATTR,
+ request.setAttribute(RequestDispatcher.ERROR_STATUS_CODE,
Integer.valueOf(statusCode));
String message = response.getMessage();
if (message == null)
message = "";
- request.setAttribute(Globals.ERROR_MESSAGE_ATTR, message);
+ request.setAttribute(RequestDispatcher.ERROR_MESSAGE, message);
request.setAttribute
(ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
errorPage.getLocation());
Wrapper wrapper = request.getWrapper();
if (wrapper != null)
- request.setAttribute(Globals.SERVLET_NAME_ATTR,
+ request.setAttribute(RequestDispatcher.ERROR_SERVLET_NAME,
wrapper.getName());
- request.setAttribute(Globals.EXCEPTION_PAGE_ATTR,
+ request.setAttribute(RequestDispatcher.ERROR_REQUEST_URI,
request.getRequestURI());
if (custom(request, response, errorPage)) {
try {
import java.io.IOException;
import javax.servlet.DispatcherType;
+import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.UnavailableException;
import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.Context;
-import org.apache.catalina.Globals;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.comet.CometEvent;
import org.apache.catalina.comet.CometProcessor;
*/
private void exception(Request request, Response response,
Throwable exception) {
- request.setAttribute(Globals.EXCEPTION_ATTR, exception);
+ request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, exception);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
import java.util.StringTokenizer;
import java.util.Vector;
+import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
-import org.apache.catalina.Globals;
import org.apache.catalina.util.IOTools;
boolean isIncluded = false;
// Look to see if this request is an include
- if (req.getAttribute(Globals.INCLUDE_REQUEST_URI_ATTR) != null) {
+ if (req.getAttribute(
+ RequestDispatcher.INCLUDE_REQUEST_URI) != null) {
isIncluded = true;
}
if (isIncluded) {
this.contextPath = (String) req.getAttribute(
- Globals.INCLUDE_CONTEXT_PATH_ATTR);
+ RequestDispatcher.INCLUDE_CONTEXT_PATH);
this.servletPath = (String) req.getAttribute(
- Globals.INCLUDE_SERVLET_PATH_ATTR);
+ RequestDispatcher.INCLUDE_SERVLET_PATH);
this.pathInfo = (String) req.getAttribute(
- Globals.INCLUDE_PATH_INFO_ATTR);
+ RequestDispatcher.INCLUDE_PATH_INFO);
} else {
this.contextPath = req.getContextPath();
this.servletPath = req.getServletPath();
String qs;
if (isIncluded) {
qs = (String) req.getAttribute(
- Globals.INCLUDE_QUERY_STRING_ATTR);
+ RequestDispatcher.INCLUDE_QUERY_STRING);
} else {
qs = req.getQueryString();
}
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
+import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
// subclasses can change this behaviour.
// Are we being processed by a RequestDispatcher.include()?
- if (request.getAttribute(Globals.INCLUDE_REQUEST_URI_ATTR) != null) {
+ if (request.getAttribute(
+ RequestDispatcher.INCLUDE_REQUEST_URI) != null) {
String result = (String) request.getAttribute(
- Globals.INCLUDE_PATH_INFO_ATTR);
+ RequestDispatcher.INCLUDE_PATH_INFO);
if (result == null) {
result = (String) request.getAttribute(
- Globals.INCLUDE_SERVLET_PATH_ATTR);
+ RequestDispatcher.INCLUDE_SERVLET_PATH);
} else {
result = (String) request.getAttribute(
- Globals.INCLUDE_SERVLET_PATH_ATTR) + result;
+ RequestDispatcher.INCLUDE_SERVLET_PATH) + result;
}
if ((result == null) || (result.equals(""))) {
result = "/";
// Check if we're included so we can return the appropriate
// missing resource name in the error
String requestUri = (String) request.getAttribute(
- Globals.INCLUDE_REQUEST_URI_ATTR);
+ RequestDispatcher.INCLUDE_REQUEST_URI);
if (requestUri == null) {
requestUri = request.getRequestURI();
} else {
// Check if we're included so we can return the appropriate
// missing resource name in the error
String requestUri = (String) request.getAttribute(
- Globals.INCLUDE_REQUEST_URI_ATTR);
+ RequestDispatcher.INCLUDE_REQUEST_URI);
if (requestUri == null) {
requestUri = request.getRequestURI();
}
if (cacheEntry.context == null) {
// Checking If headers
- boolean included =
- (request.getAttribute(Globals.INCLUDE_CONTEXT_PATH_ATTR) != null);
+ boolean included = (request.getAttribute(
+ RequestDispatcher.INCLUDE_CONTEXT_PATH) != null);
if (!included && !isError &&
!checkIfHeaders(request, response, cacheEntry.attributes)) {
return;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
+import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.UnavailableException;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import org.apache.catalina.Globals;
import org.apache.catalina.util.DOMWriter;
import org.apache.catalina.util.MD5Encoder;
import org.apache.catalina.util.RequestUtil;
@Override
protected String getRelativePath(HttpServletRequest request) {
// Are we being processed by a RequestDispatcher.include()?
- if (request.getAttribute(Globals.INCLUDE_REQUEST_URI_ATTR) != null) {
+ if (request.getAttribute(
+ RequestDispatcher.INCLUDE_REQUEST_URI) != null) {
String result = (String) request.getAttribute(
- Globals.INCLUDE_PATH_INFO_ATTR);
+ RequestDispatcher.INCLUDE_PATH_INFO);
if ((result == null) || (result.equals("")))
result = "/";
return (result);
else if (nameParts[1].equals("URI")) {
// If this is an error page, get the original URI
retVal = (String) req.getAttribute(
- "javax.servlet.forward.request_uri");
+ RequestDispatcher.FORWARD_REQUEST_URI);
if (retVal == null) retVal=req.getRequestURI();
}
} else if (nameParts[0].equals("SCRIPT")) {
package org.apache.catalina.ssi;
+import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import org.apache.catalina.util.RequestUtil;
*/
public static String getRelativePath(HttpServletRequest request) {
// Are we being processed by a RequestDispatcher.include()?
- if (request.getAttribute("javax.servlet.include.request_uri") != null) {
- String result = (String)request
- .getAttribute("javax.servlet.include.path_info");
+ if (request.getAttribute(
+ RequestDispatcher.INCLUDE_REQUEST_URI) != null) {
+ String result = (String)request.getAttribute(
+ RequestDispatcher.INCLUDE_PATH_INFO);
if (result == null)
- result = (String)request
- .getAttribute("javax.servlet.include.servlet_path");
+ result = (String)request.getAttribute(
+ RequestDispatcher.INCLUDE_SERVLET_PATH);
if ((result == null) || (result.equals(""))) result = "/";
return (result);
}
import java.io.IOException;
import java.io.Writer;
+import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
-import org.apache.catalina.Globals;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
import org.apache.catalina.util.RequestUtil;
}
Throwable throwable =
- (Throwable) request.getAttribute(Globals.EXCEPTION_ATTR);
+ (Throwable) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
if (throwable != null) {
import javax.servlet.ServletException;
+import org.apache.catalina.Globals;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
* @version $Id$
*/
-public class SSLValve
- extends ValveBase {
+public class SSLValve extends ValveBase {
//------------------------------------------------------ Constructor
System.out.println("SSLValve failed " + strcerts);
System.out.println("SSLValve failed " + e);
}
- request.setAttribute("javax.servlet.request.X509Certificate", jsseCerts);
+ request.setAttribute(Globals.CERTIFICATES_ATTR, jsseCerts);
}
strcert0 = mygetHeader(request, "ssl_cipher");
if (strcert0 != null) {
- request.setAttribute("javax.servlet.request.cipher_suite", strcert0);
+ request.setAttribute(Globals.CIPHER_SUITE_ATTR, strcert0);
}
strcert0 = mygetHeader(request, "ssl_session_id");
if (strcert0 != null) {
- request.setAttribute("javax.servlet.request.ssl_session", strcert0);
+ request.setAttribute(Globals.SSL_SESSION_ID_ATTR, strcert0);
}
strcert0 = mygetHeader(request, "ssl_cipher_usekeysize");
if (strcert0 != null) {
- request.setAttribute("javax.servlet.request.key_size", strcert0);
+ request.setAttribute(Globals.KEY_SIZE_ATTR, strcert0);
}
getNext().invoke(request, response);
}
import org.apache.tomcat.util.http.MimeHeaders;
import org.apache.tomcat.util.net.AbstractEndpoint;
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
+import org.apache.tomcat.util.net.SSLSupport;
import org.apache.tomcat.util.res.StringManager;
/**
getLog().error(sm.getString("ajpprocessor.certs.fail"), e);
return;
}
- request.setAttribute(AbstractEndpoint.CERTIFICATE_KEY, jsseCerts);
+ request.setAttribute(SSLSupport.CERTIFICATE_KEY, jsseCerts);
}
} else if (actionCode == ActionCode.REQ_HOST_ATTRIBUTE) {
case Constants.SC_A_SSL_CIPHER :
request.scheme().setString("https");
requestHeaderMessage.getBytes(tmpMB);
- request.setAttribute(AbstractEndpoint.CIPHER_SUITE_KEY,
+ request.setAttribute(SSLSupport.CIPHER_SUITE_KEY,
tmpMB.toString());
break;
case Constants.SC_A_SSL_SESSION :
request.scheme().setString("https");
requestHeaderMessage.getBytes(tmpMB);
- request.setAttribute(AbstractEndpoint.SESSION_ID_KEY,
+ request.setAttribute(SSLSupport.SESSION_ID_KEY,
tmpMB.toString());
break;
case Constants.SC_A_SSL_KEY_SIZE :
- request.setAttribute(AbstractEndpoint.KEY_SIZE_KEY,
+ request.setAttribute(SSLSupport.KEY_SIZE_KEY,
Integer.valueOf(requestHeaderMessage.getInt()));
break;
import org.apache.tomcat.util.net.AbstractEndpoint;
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
import org.apache.tomcat.util.net.AprEndpoint;
+import org.apache.tomcat.util.net.SSLSupport;
import org.apache.tomcat.util.net.SocketStatus;
import org.apache.tomcat.util.net.SocketWrapper;
// Cipher suite
Object sslO = SSLSocket.getInfoS(socketRef, SSL.SSL_INFO_CIPHER);
if (sslO != null) {
- request.setAttribute(AbstractEndpoint.CIPHER_SUITE_KEY, sslO);
+ request.setAttribute(SSLSupport.CIPHER_SUITE_KEY, sslO);
}
// Get client certificate and the certificate chain if present
// certLength == -1 indicates an error
}
}
if (certs != null) {
- request.setAttribute(AbstractEndpoint.CERTIFICATE_KEY, certs);
+ request.setAttribute(SSLSupport.CERTIFICATE_KEY, certs);
}
// User key size
sslO = Integer.valueOf(SSLSocket.getInfoI(socketRef,
SSL.SSL_INFO_CIPHER_USEKEYSIZE));
- request.setAttribute(AbstractEndpoint.KEY_SIZE_KEY, sslO);
+ request.setAttribute(SSLSupport.KEY_SIZE_KEY, sslO);
// SSL session ID
sslO = SSLSocket.getInfoS(socketRef, SSL.SSL_INFO_SESSION_ID);
if (sslO != null) {
- request.setAttribute(AbstractEndpoint.SESSION_ID_KEY, sslO);
+ request.setAttribute(SSLSupport.SESSION_ID_KEY, sslO);
}
//TODO provide a hook to enable the SSL session to be
// invalidated. Set AprEndpoint.SESSION_MGR req attr
}
}
if (certs != null) {
- request.setAttribute(AbstractEndpoint.CERTIFICATE_KEY, certs);
+ request.setAttribute(SSLSupport.CERTIFICATE_KEY, certs);
}
}
} catch (Exception e) {
public static final String TAG_FILE_PACKAGE_NAME =
System.getProperty("org.apache.jasper.Constants.TAG_FILE_PACKAGE_NAME", "org.apache.jsp.tag");
- /**
- * Servlet context and request attributes that the JSP engine
- * uses.
- */
- public static final String INC_SERVLET_PATH = "javax.servlet.include.servlet_path";
-
// Must be kept in sync with org/apache/catalina/Globals.java
public static final String ALT_DD_ATTR =
System.getProperty("org.apache.jasper.Constants.ALT_DD_ATTR", "org.apache.catalina.deploy.alt_dd");
*/
public class JspRuntimeLibrary {
- private static final String SERVLET_EXCEPTION
- = "javax.servlet.error.exception";
- private static final String JSP_EXCEPTION
- = "javax.servlet.jsp.jspException";
-
protected static class PrivilegedIntrospectHelper
implements PrivilegedExceptionAction<Void> {
* variable is initialized.
*/
public static Throwable getThrowable(ServletRequest request) {
- Throwable error = (Throwable) request.getAttribute(SERVLET_EXCEPTION);
+ Throwable error = (Throwable) request.getAttribute(
+ RequestDispatcher.ERROR_EXCEPTION);
if (error == null) {
- error = (Throwable) request.getAttribute(JSP_EXCEPTION);
+ error = (Throwable) request.getAttribute(PageContext.EXCEPTION);
if (error != null) {
/*
* The only place that sets JSP_EXCEPTION is
* ErrorReportValve. Therefore, if JSP_EXCEPTION is set, we
* need to set SERVLET_EXCEPTION.
*/
- request.setAttribute(SERVLET_EXCEPTION, error);
+ request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, error);
}
}
if (!(request instanceof HttpServletRequest))
return (relativePath);
HttpServletRequest hrequest = (HttpServletRequest) request;
- String uri = (String)
- request.getAttribute("javax.servlet.include.servlet_path");
+ String uri = (String) request.getAttribute(
+ RequestDispatcher.INCLUDE_SERVLET_PATH);
if (uri != null) {
String pathInfo = (String)
- request.getAttribute("javax.servlet.include.path_info");
+ request.getAttribute(RequestDispatcher.INCLUDE_PATH_INFO);
if (pathInfo == null) {
if (uri.lastIndexOf('/') >= 0)
uri = uri.substring(0, uri.lastIndexOf('/'));
import javax.el.ELContext;
import javax.el.ExpressionFactory;
import javax.el.ValueExpression;
+import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.jsp.el.VariableResolver;
import javax.servlet.jsp.tagext.BodyContent;
-import org.apache.jasper.Constants;
import org.apache.jasper.compiler.Localizer;
import org.apache.jasper.el.ELContextImpl;
import org.apache.jasper.el.ExpressionEvaluatorImpl;
setAttribute(PAGECONTEXT, this);
setAttribute(APPLICATION, context);
- isIncluded = request.getAttribute("javax.servlet.include.servlet_path") != null;
+ isIncluded = request.getAttribute(
+ RequestDispatcher.INCLUDE_SERVLET_PATH) != null;
}
@Override
String path = relativeUrlPath;
if (!path.startsWith("/")) {
- String uri = (String) request
- .getAttribute("javax.servlet.include.servlet_path");
+ String uri = (String) request.getAttribute(
+ RequestDispatcher.INCLUDE_SERVLET_PATH);
if (uri == null)
uri = ((HttpServletRequest) request).getServletPath();
String baseURI = uri.substring(0, uri.lastIndexOf('/'));
}
final String path = getAbsolutePathRelativeToContext(relativeUrlPath);
- String includeUri = (String) request
- .getAttribute(Constants.INC_SERVLET_PATH);
+ String includeUri = (String) request.getAttribute(
+ RequestDispatcher.INCLUDE_SERVLET_PATH);
if (includeUri != null)
- request.removeAttribute(Constants.INC_SERVLET_PATH);
+ request.removeAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH);
try {
context.getRequestDispatcher(path).forward(request, response);
} finally {
if (includeUri != null)
- request.setAttribute(Constants.INC_SERVLET_PATH, includeUri);
+ request.setAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH,
+ includeUri);
}
}
* not been committed (the response will have been committed if the
* error page is a JSP page).
*/
- request.setAttribute("javax.servlet.jsp.jspException", t);
- request.setAttribute("javax.servlet.error.status_code",
+ request.setAttribute(PageContext.EXCEPTION, t);
+ request.setAttribute(RequestDispatcher.ERROR_STATUS_CODE,
new Integer(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
- request.setAttribute("javax.servlet.error.request_uri",
+ request.setAttribute(RequestDispatcher.ERROR_REQUEST_URI,
((HttpServletRequest) request).getRequestURI());
- request.setAttribute("javax.servlet.error.servlet_name", config
- .getServletName());
+ request.setAttribute(RequestDispatcher.ERROR_SERVLET_NAME,
+ config.getServletName());
try {
forward(errorPageURL);
} catch (IllegalStateException ise) {
// The error page could be inside an include.
- Object newException = request
- .getAttribute("javax.servlet.error.exception");
+ Object newException =
+ request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
// t==null means the attribute was not set.
if ((newException != null) && (newException == t)) {
- request.removeAttribute("javax.servlet.error.exception");
+ request.removeAttribute(RequestDispatcher.ERROR_EXCEPTION);
}
// now clear the error code - to prevent double handling.
- request.removeAttribute("javax.servlet.error.status_code");
- request.removeAttribute("javax.servlet.error.request_uri");
- request.removeAttribute("javax.servlet.error.status_code");
- request.removeAttribute("javax.servlet.jsp.jspException");
+ request.removeAttribute(RequestDispatcher.ERROR_STATUS_CODE);
+ request.removeAttribute(RequestDispatcher.ERROR_REQUEST_URI);
+ request.removeAttribute(RequestDispatcher.ERROR_SERVLET_NAME);
+ request.removeAttribute(PageContext.EXCEPTION);
} else {
// Otherwise throw the exception wrapped inside a ServletException.
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
+import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
* Check to see if the requested JSP has been the target of a
* RequestDispatcher.include()
*/
- jspUri = (String) request.getAttribute(Constants.INC_SERVLET_PATH);
+ jspUri = (String) request.getAttribute(
+ RequestDispatcher.INCLUDE_SERVLET_PATH);
if (jspUri != null) {
/*
* Requested JSP has been target of
* relevant javax.servlet.include.* request attributes
*/
String pathInfo = (String) request.getAttribute(
- "javax.servlet.include.path_info");
+ RequestDispatcher.INCLUDE_PATH_INFO);
if (pathInfo != null) {
jspUri += pathInfo;
}
throws ServletException, IOException {
String includeRequestUri =
- (String)request.getAttribute("javax.servlet.include.request_uri");
+ (String)request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI);
if (includeRequestUri != null) {
// This file was included. Throw an exception as
import java.io.FileNotFoundException;
import java.io.IOException;
+import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
}
} catch (UnavailableException ex) {
String includeRequestUri = (String)
- request.getAttribute("javax.servlet.include.request_uri");
+ request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI);
if (includeRequestUri != null) {
// This file was included. Throw an exception as
// a response.sendError() will be ignored by the
// -------------------------------------------------------------- Constants
protected static final StringManager sm = StringManager.getManager("org.apache.tomcat.util.net.res");
- /**
- * The Request attribute key for the cipher suite.
- */
- public static final String CIPHER_SUITE_KEY = "javax.servlet.request.cipher_suite";
-
- /**
- * The Request attribute key for the key size.
- */
- public static final String KEY_SIZE_KEY = "javax.servlet.request.key_size";
-
- /**
- * The Request attribute key for the client certificate chain.
- */
- public static final String CERTIFICATE_KEY = "javax.servlet.request.X509Certificate";
-
- /**
- * The Request attribute key for the session id.
- * This one is a Tomcat extension to the Servlet spec.
- */
- public static final String SESSION_ID_KEY = "javax.servlet.request.ssl_session";
-
- /**
- * The request attribute key for the session manager.
- * This one is a Tomcat extension to the Servlet spec.
- */
- public static final String SESSION_MGR = "javax.servlet.request.ssl_session_mgr";
-
public static interface Handler {
/**
* Different types of socket states to react upon.
/**
* The Request attribute key for the cipher suite.
*/
- public static final String CIPHER_SUITE_KEY = "javax.servlet.request.cipher_suite";
+ public static final String CIPHER_SUITE_KEY =
+ "javax.servlet.request.cipher_suite";
/**
* The Request attribute key for the key size.
/**
* The Request attribute key for the client certificate chain.
*/
- public static final String CERTIFICATE_KEY = "javax.servlet.request.X509Certificate";
+ public static final String CERTIFICATE_KEY =
+ "javax.servlet.request.X509Certificate";
/**
* The Request attribute key for the session id.
* This one is a Tomcat extension to the Servlet spec.
*/
- public static final String SESSION_ID_KEY = "javax.servlet.request.ssl_session";
+ public static final String SESSION_ID_KEY =
+ "javax.servlet.request.ssl_session";
/**
* The request attribute key for the session manager.
* This one is a Tomcat extension to the Servlet spec.
*/
public static final String SESSION_MGR =
- "javax.servlet.request.ssl_session_mgr";
+ "javax.servlet.request.ssl_session_mgr";
/**