Index: java/org/apache/catalina/Context.java =================================================================== --- java/org/apache/catalina/Context.java (revision 1005400) +++ java/org/apache/catalina/Context.java (working copy) @@ -325,6 +325,35 @@ * @param docBase The new document root */ public void setDocBase(String docBase); + + + /** + * Is URL rewriting disabled? + * URL rewriting is an optional component of the servlet 2.5 specification. + * However if set to true this will be non-compliant with the specification + * as the specification requires that there must be a way to retain + * sessions if the client doesn't allow session cookies. + * + * @return true If URL rewriting is disabled. + * + * @see Servlet + * 2.5 Specification. Sections SRV.7.1.3 and SRV.7.1.4 + * @see javax.servlet.http.HttpServletResponse#encodeURL(String) encodeURL + * @see javax.servlet.http.HttpServletResponse#encodeRedirectURL(String) + * encodeRedirectURL + */ + public boolean isDisableURLRewriting(); + + /** + * Is URL rewriting disabled? + * URL rewriting is an optional component of the servlet 2.5 specification. + * However if set to true this will be non-compliant with the specification + * as the specification requires that there must be a way to retain + * sessions if the client doesn't allow session cookies. + * + * @param disable True to disable URL Rewriting. Default false. + */ + public void setDisableURLRewriting(boolean disable); /** Index: java/org/apache/catalina/connector/CoyoteAdapter.java =================================================================== --- java/org/apache/catalina/connector/CoyoteAdapter.java (revision 1005191) +++ java/org/apache/catalina/connector/CoyoteAdapter.java (working copy) @@ -462,6 +462,13 @@ connector.getMapper().map(serverName, decodedURI, request.getMappingData()); request.setContext((Context) request.getMappingData().context); + + // Had to do this after the context was set. + // Unfortunately parseSessionId is still necessary as it + // affects the final URL. Safe as session cookies still + // haven't been parsed. + if (isURLRewritingDisabled(request)) + clearRequestedSessionURL(request); request.setWrapper((Wrapper) request.getMappingData().wrapper); // Filter trace method @@ -516,6 +523,13 @@ return true; } + private boolean isURLRewritingDisabled(Request request) { + Context context = (Context) request.getMappingData().context; + if (context != null) + return (context.isDisableURLRewriting()); + else + return (false); + } /** * Parse session id in URL. @@ -560,19 +574,22 @@ } request.setRequestedSessionURL(true); } catch (UnsupportedEncodingException uee) { - // Make sure no session ID is returned - request.setRequestedSessionId(null); - request.setRequestedSessionURL(false); + clearRequestedSessionURL(request); log.warn(sm.getString("coyoteAdapter.parseSession", enc), uee); } } else { - request.setRequestedSessionId(null); - request.setRequestedSessionURL(false); + clearRequestedSessionURL(request); } } + private void clearRequestedSessionURL(Request request) { + request.setRequestedSessionId(null); + request.setRequestedSessionURL(false); + } + + /** * Parse session id in URL. */ Index: java/org/apache/catalina/connector/Response.java =================================================================== --- java/org/apache/catalina/connector/Response.java (revision 1005191) +++ java/org/apache/catalina/connector/Response.java (working copy) @@ -1479,12 +1479,14 @@ *
  • The requested session ID was not received via a cookie *
  • The specified URL points back to somewhere within the web * application that is responding to this request + *
  • If URL rewriting hasn't been disabled for this context * * * @param location Absolute URL to be validated */ protected boolean isEncodeable(final String location) { - + if (getContext().isDisableURLRewriting()) + return (false); if (location == null) return (false); Index: java/org/apache/catalina/core/StandardContext.java =================================================================== --- java/org/apache/catalina/core/StandardContext.java (revision 1005191) +++ java/org/apache/catalina/core/StandardContext.java (working copy) @@ -341,6 +341,12 @@ /** + * Has URL rewriting been disabled. + */ + private boolean disableURLRewriting = false; + + + /** * The exception pages for this web application, keyed by fully qualified * class name of the Java exception. */ @@ -1461,6 +1467,37 @@ this.docBase = docBase; } + + /** + * Is URL rewriting disabled? + * URL rewriting is an optional component of the servlet 2.5 specification. + * However if set to true this will be non-compliant with the specification + * as the specification requires that there must be a way to retain + * sessions if the client doesn't allow session cookies. + * + * @return true If URL rewriting is disabled. + * + * @see Servlet + * 2.5 Specification. Sections SRV.7.1.3 and SRV.7.1.4 + * @see javax.servlet.http.HttpServletResponse#encodeURL(String) encodeURL + * @see javax.servlet.http.HttpServletResponse#encodeRedirectURL(String) + * encodeRedirectURL + */ + public boolean isDisableURLRewriting() { + return (this.disableURLRewriting); + } + + /** + * Sets the disabling of URL Rewriting. + * @param disable True to disable URL Rewriting. Default false. + */ + public void setDisableURLRewriting(boolean disable){ + boolean oldDisableURLRewriting = this.isDisableURLRewriting(); + this.disableURLRewriting = disable; + support.firePropertyChange("disableURLRewriting", + oldDisableURLRewriting, disableURLRewriting); + + } // experimental public boolean isLazy() { Index: java/org/apache/catalina/core/mbeans-descriptors.xml =================================================================== --- java/org/apache/catalina/core/mbeans-descriptors.xml (revision 1005191) +++ java/org/apache/catalina/core/mbeans-descriptors.xml (working copy) @@ -135,6 +135,11 @@ description="String deployment descriptor " type="java.lang.String"/> + +