As a quick Nginx configuration example, if you need to configure a 301 Redirect with Nginx, and you also need to account for trailing slash characters in the original URL, I can confirm that this solution works for me:
rewrite /foo/bar/baz/?$ /foo/bar/baz.html permanent;
This Nginx configuration line will forward both of these URIs to the new URI:
Note: This approach is very old; Java/JSP scriptlets were deprecated a long time ago. I don't have time to update this article to the correct, modern approach, but I hope this JSP session example will point you in the right direction.
Every once in a while I'm asked something like, "How can I tell if I have a valid user session in my JSP code?"
When you need to forward from one JavaServer Page (JSP) to another JSP, here's all you have to do:
<jsp:forward page="/faces/success.jsp" />
In the example shown I happen to be working on a small JavaServer Faces (JSF) application, so the URL in this example includes the string
Java servlet redirect FAQ: Can you provide an example of how to perform a Java servlet redirect?
Some time ago I wrote about forwarding from a servlet to a JSP. Depending on the circumstance I might rather redirect from a servlet to a JSP. When I need to to do a redirect instead of a forward I use this code:
Here's an example of how to forward from a servlet to a JSP in your J2EE code. I can never remember how to do a forward like this when I need it, so even though this example is pretty easy, I've put it out here so I can find it later.
The typical scenario is that you're working on a Java servlet, and you need to forward the user from that servlet to a JSP. Assuming the name of the JSP is "
searchResults.jsp", here's the code that will forward from your servlet to that JSP: