Skip to content

Commit

Permalink
Fix return and code links when request URI has a pathInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
markt-asf committed Dec 2, 2024
1 parent 64abd53 commit fed4ac6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
4 changes: 4 additions & 0 deletions webapps/docs/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
25 changes: 12 additions & 13 deletions webapps/examples/WEB-INF/classes/RequestInfoExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,18 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro
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>");
Expand Down

0 comments on commit fed4ac6

Please sign in to comment.