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 @@ *