This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit c9c80c782a30c15e3c6aac621972f9f127b71c01 Author: Mark Thomas <ma...@apache.org> AuthorDate: Mon Dec 2 15:30:46 2024 +0000 Fix return and code links when request URI has a pathInfo --- webapps/docs/changelog.xml | 4 ++++ .../WEB-INF/classes/RequestInfoExample.java | 25 +++++++++++----------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index ea56af62b3..4a15dcd05d 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -242,6 +242,10 @@ <code>allowedInternalProxies</code>. Pull request <pr>786</pr> provided by Jorge Díaz. (markt) </fix> + <fix> + Examples. Fix broken links when Servlet Request Info example is called + via a URL that includes a pathInfo component. (markt) + </fix> </changelog> </subsection> <subsection name = "Other"> diff --git a/webapps/examples/WEB-INF/classes/RequestInfoExample.java b/webapps/examples/WEB-INF/classes/RequestInfoExample.java index 57665bb2c5..1538f5bc89 100644 --- a/webapps/examples/WEB-INF/classes/RequestInfoExample.java +++ b/webapps/examples/WEB-INF/classes/RequestInfoExample.java @@ -53,19 +53,18 @@ public class RequestInfoExample extends HttpServlet { out.println("</head>"); out.println("<body bgcolor=\"white\">"); - // img stuff not req'd for source code HTML showing - // all links relative! - - // XXX - // making these absolute till we work out the - // addition of a PathInfo issue - - out.println("<a href=\"../reqinfo.html\">"); - out.println( - "<img src=\"../images/code.gif\" height=24 " + "width=24 align=right border=0 alt=\"view code\"></a>"); - out.println("<a href=\"../index.html\">"); - out.println( - "<img src=\"../images/return.gif\" height=24 " + "width=24 align=right border=0 alt=\"return\"></a>"); + /* + * Can't use relative paths since this servlet might have pathInfo. Allows for deployment to a different context + * path but otherwise assumes that the web application structure is not changed. + */ + String baseURI = request.getServletContext().getContextPath() + "/servlets"; + + out.println("<a href=\"" + baseURI + "/reqinfo.html\">"); + out.println("<img src=\"" + baseURI + "/images/code.gif\" height=24 " + + "width=24 align=right border=0 alt=\"view code\"></a>"); + out.println("<a href=\"" + baseURI + "/index.html\">"); + out.println("<img src=\"" + baseURI + "/images/return.gif\" height=24 " + + "width=24 align=right border=0 alt=\"return\"></a>"); out.println("<h3>" + title + "</h3>"); out.println("<table border=0><tr><td>"); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org