Chirs, first, thanks for your answers, and also for the nits, they did hit some good points. Then on with some answers to the further questions you placed;
On Tue, Dec 11, 2012 at 12:58 AM, Christopher Schultz <ch...@christopherschultz.net> wrote: > On 12/10/12 5:40 PM, Christopher Schultz wrote: >> I'll take a look. You definitely want to use URLs that start with >> "/" in all cases to prevent this kind of ambiguity. > > So it looks like I'm wrong and there may in fact be a bug in Tomcat. > > Servlet 3.0 has this to say about "forward" in section 9.4: > > " > The path elements of the request object exposed to the target servlet > must reflect the path used to obtain the RequestDispatcher. > " Thanks, I did read the Servlet spec 2.5, but at least didn't come across this statement there. > Your forward() code looks like this: > >> RequestDispatcher rd = application.getRequestDispatcher("/"); >> rd.forward(request, response); > > So the path used to obtain the RequestDispatcher is "/" and URLs built > should be relative to that. ... so looks like I might have encountered a minor bug. > Are you using Tomcat's provided JSTL, or do you bundle one with your > own webapp? This was good call, too - something I hadn't been paying attention to. In the example I seem to be using JSTL library from some version of Glassfish (a Maven dependency, javax.servlet:jstl:1.2, which gets packaged into the examle webapp). What JSTL implementation is used in the original place where I encountered this, I don't know (could check, but I think for now we can just as well concentrate on this example, as it exhibits the same behaviour as the original case). > Can you post a copy of the .java source generated from your JSP that > contains the <c:redirect>? Certainly; and this seems to hit another point where I've been sloppy; this example has been run on Tomcat embedded with NetBeans, and thus version 7.0.27. And interesting, this seems to refer to org.apache.taglibs.standard for the RegirectTag implementation, despite the other JSTL lib being included in the application: /* * Generated by the Jasper component of Apache Tomcat * Version: Apache Tomcat/7.0.27 * Generated at: 2012-12-10 20:52:07 UTC * Note: The last modified time of this file was set to * the last modified time of the source file after * generation to assist with modification tracking. */ package org.apache.jsp; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.jsp.*; public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase implements org.apache.jasper.runtime.JspSourceDependent { private static final javax.servlet.jsp.JspFactory _jspxFactory = javax.servlet.jsp.JspFactory.getDefaultFactory(); private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants; private org.apache.jasper.runtime.TagHandlerPool _005fjspx_005ftagPool_005fc_005fredirect_0026_005furl_005fnobody; private javax.el.ExpressionFactory _el_expressionfactory; private org.apache.tomcat.InstanceManager _jsp_instancemanager; public java.util.Map<java.lang.String,java.lang.Long> getDependants() { return _jspx_dependants; } public void _jspInit() { _005fjspx_005ftagPool_005fc_005fredirect_0026_005furl_005fnobody = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig()); _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory(); _jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig()); } public void _jspDestroy() { _005fjspx_005ftagPool_005fc_005fredirect_0026_005furl_005fnobody.release(); } public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException { final javax.servlet.jsp.PageContext pageContext; javax.servlet.http.HttpSession session = null; final javax.servlet.ServletContext application; final javax.servlet.ServletConfig config; javax.servlet.jsp.JspWriter out = null; final java.lang.Object page = this; javax.servlet.jsp.JspWriter _jspx_out = null; javax.servlet.jsp.PageContext _jspx_page_context = null; try { response.setContentType("text/html;charset=UTF-8"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("\r\n"); out.write("\r\n"); out.write("<!DOCTYPE html>\r\n"); out.write("\r\n"); if (_jspx_meth_c_005fredirect_005f0(_jspx_page_context)) return; out.write('\r'); out.write('\n'); } catch (java.lang.Throwable t) { if (!(t instanceof javax.servlet.jsp.SkipPageException)){ out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { out.clearBuffer(); } catch (java.io.IOException e) {} if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } } private boolean _jspx_meth_c_005fredirect_005f0(javax.servlet.jsp.PageContext _jspx_page_context) throws java.lang.Throwable { javax.servlet.jsp.PageContext pageContext = _jspx_page_context; javax.servlet.jsp.JspWriter out = _jspx_page_context.getOut(); // c:redirect org.apache.taglibs.standard.tag.rt.core.RedirectTag _jspx_th_c_005fredirect_005f0 = (org.apache.taglibs.standard.tag.rt.core.RedirectTag) _005fjspx_005ftagPool_005fc_005fredirect_0026_005furl_005fnobody.get(org.apache.taglibs.standard.tag.rt.core.RedirectTag.class); _jspx_th_c_005fredirect_005f0.setPageContext(_jspx_page_context); _jspx_th_c_005fredirect_005f0.setParent(null); // /index.jsp(5,0) name = url type = null reqTime = true required = false fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null _jspx_th_c_005fredirect_005f0.setUrl("sub/page.jsp"); int _jspx_eval_c_005fredirect_005f0 = _jspx_th_c_005fredirect_005f0.doStartTag(); if (_jspx_th_c_005fredirect_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { _005fjspx_005ftagPool_005fc_005fredirect_0026_005furl_005fnobody.reuse(_jspx_th_c_005fredirect_005f0); return true; } _005fjspx_005ftagPool_005fc_005fredirect_0026_005furl_005fnobody.reuse(_jspx_th_c_005fredirect_005f0); return false; } } -- ..Juha --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org