Tomcat 5.5 redirect vs. forward behavior with welcome-file-list
In Tomcat 4.1, a request to a directory containing a welcome-file would *redirect* the user to a URL with any applicable welcome-file's name appended. In Tomcat 5.5, the request is instead *forwarded* to the welcome file. Is there a way to make Tomcat 5.5 act like Tomcat 4.1 in this respect? For example: I have a web.xml which contains: index.jsp In Tomcat 4.1, a request to http://www.mysite.com/directory/ makes the browser refresh with a URL of http://www.mysite.com/directory/index.jsp In Tomcat 5.5, the same request leaves the browser with the same URL http://www.mysite.com/directory/. BACKGROUND: I'm using Tomcat 5.5.17 on Windows XP, and unfortunately, my application is dependent on the redirect behavior of Tomcat 4.1 because my JSPs use HttpServletRequest.getRequestURI() to find the name of the JSPs themselves. The JSPs pull their content from the database based on the URL being requested. So, if the browser's URL bar reads http://www.mysite.com/directory/index.jsp, the 'index.jsp' queries the DB for content based on the path '/directory/index.jsp'. Conversely, if the browser's URL bar reads http://www.mysite.com/directory/, the same JSP looks for database rows using the path '/directory/'. Naturally, because Tomcat 5.5 acts differently, similar requests receive different content. I realize that populating content based on what's in the URL bar is not the best design, but I can't seem to find another way to definitively get the name of the actual JSP being requested. If anybody knows of a method similar to getRequestURI(), but which knows the name of the JSP being requested, it would help tremendously. Thanks, Todd - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat 5.5 redirect vs. forward behavior with welcome-file-list
Todd Gamber schrieb: In Tomcat 4.1, a request to a directory containing a welcome-file would *redirect* the user to a URL with any applicable welcome-file's name appended. In Tomcat 5.5, the request is instead *forwarded* to the welcome file. Is there a way to make Tomcat 5.5 act like Tomcat 4.1 in this respect? For example: I have a web.xml which contains: index.jsp In Tomcat 4.1, a request to http://www.mysite.com/directory/ makes the browser refresh with a URL of http://www.mysite.com/directory/index.jsp In Tomcat 5.5, the same request leaves the browser with the same URL http://www.mysite.com/directory/. BACKGROUND: I'm using Tomcat 5.5.17 on Windows XP, and unfortunately, my application is dependent on the redirect behavior of Tomcat 4.1 because my JSPs use HttpServletRequest.getRequestURI() to find the name of the JSPs themselves. The JSPs pull their content from the database based on the URL being requested. So, if the browser's URL bar reads http://www.mysite.com/directory/index.jsp, the 'index.jsp' queries the DB for content based on the path '/directory/index.jsp'. Conversely, if the browser's URL bar reads http://www.mysite.com/directory/, the same JSP looks for database rows using the path '/directory/'. Naturally, because Tomcat 5.5 acts differently, similar requests receive different content. I realize that populating content based on what's in the URL bar is not the best design, but I can't seem to find another way to definitively get the name of the actual JSP being requested. If anybody knows of a method similar to getRequestURI(), but which knows the name of the JSP being requested, it would help tremendously. Thanks, Todd - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Hi Todd, I don't know if their is some configuration attribute but a servlet filter could be an option. Good luck -- Stefan - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat 5.5 redirect vs. forward behavior with welcome-file-list
Todd Gamber schrieb: In Tomcat 4.1, a request to a directory containing a welcome-file would *redirect* the user to a URL with any applicable welcome-file's name appended. In Tomcat 5.5, the request is instead *forwarded* to the welcome file. Is there a way to make Tomcat 5.5 act like Tomcat 4.1 in this respect? For example: I have a web.xml which contains: index.jsp In Tomcat 4.1, a request to http://www.mysite.com/directory/ makes the browser refresh with a URL of http://www.mysite.com/directory/index.jsp In Tomcat 5.5, the same request leaves the browser with the same URL http://www.mysite.com/directory/. BACKGROUND: I'm using Tomcat 5.5.17 on Windows XP, and unfortunately, my application is dependent on the redirect behavior of Tomcat 4.1 because my JSPs use HttpServletRequest.getRequestURI() to find the name of the JSPs themselves. The JSPs pull their content from the database based on the URL being requested. So, if the browser's URL bar reads http://www.mysite.com/directory/index.jsp, the 'index.jsp' queries the DB for content based on the path '/directory/index.jsp'. Conversely, if the browser's URL bar reads http://www.mysite.com/directory/, the same JSP looks for database rows using the path '/directory/'. Naturally, because Tomcat 5.5 acts differently, similar requests receive different content. I realize that populating content based on what's in the URL bar is not the best design, but I can't seem to find another way to definitively get the name of the actual JSP being requested. If anybody knows of a method similar to getRequestURI(), but which knows the name of the JSP being requested, it would help tremendously. Thanks, Todd - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] By the way Todd. Use HttpServletRequest.getServletPath() instead of HttpServletRequest.getRequestURI(). This will report the forwarded path without the context path information. Regards Stefan -- Stefan - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat 5.5 redirect vs. forward behavior with welcome-file-list
On 2/12/07, Todd Gamber <[EMAIL PROTECTED]> wrote: I realize that populating content based on what's in the URL bar is not the best design, but I can't seem to find another way to definitively get the name of the actual JSP being requested. TSSIYF -- The Servlet Spec is your friend :-) SRV.8.4.2 Forwarded Request Parameters Except for servlets obtained by using the getNamedDispatcher method, a servlet that has been invoked by another servlet using the forward method of RequestDispatcher has access to the path of the original request. The following request attributes must be set: javax.servlet.forward.request_uri javax.servlet.forward.context_path javax.servlet.forward.servlet_path javax.servlet.forward.path_info javax.servlet.forward.query_string HTH! -- Hassan Schroeder [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tomcat 5.5 redirect vs. forward behavior with welcome-file-list
Hassan, I couldn't seem to get request.getAttribute("javax.servlet.forward.servlet_path") to work in my situation (it returns null, maybe because its being called from a custom tag?), but Stefan's suggestion of request.getServletPath() accomplishes just what I need. Thank you for your response, and to Stefan as well, Todd -Original Message- From: Hassan Schroeder [mailto:[EMAIL PROTECTED] Sent: Monday, February 12, 2007 2:52 PM To: Tomcat Users List Subject: Re: Tomcat 5.5 redirect vs. forward behavior with welcome-file-list On 2/12/07, Todd Gamber <[EMAIL PROTECTED]> wrote: > I realize that populating content based on what's in the URL bar is not the > best design, but I can't seem to find another way to definitively get the > name of the actual JSP being requested. TSSIYF -- The Servlet Spec is your friend :-) SRV.8.4.2 Forwarded Request Parameters Except for servlets obtained by using the getNamedDispatcher method, a servlet that has been invoked by another servlet using the forward method of RequestDispatcher has access to the path of the original request. The following request attributes must be set: javax.servlet.forward.request_uri javax.servlet.forward.context_path javax.servlet.forward.servlet_path javax.servlet.forward.path_info javax.servlet.forward.query_string HTH! -- Hassan Schroeder [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]