I'm not a jsp developer but i would like to make a small adjustment to a jsp page in some open source software i have.
All i want to do is find out what url i used to get to the page, let's say https://old.example.com, and if i did then i would like to redirect the user to https://new.example.com, but i don't want to get in a redirect loop obviously...
how would i go about this ...
You could try something like this:
<%
if(request.getRequestURL().toString().equals("https://old.example.com")){
String redirectURL = "https://new.example.com";
response.sendRedirect(redirectURL);
}
%>
And in case you don't prefer java code inside your JSP (which is a bad programming practice), you could try something like this using JSTL
<c:if test="${pageContext.request.requestURL == 'https://old.example.com'}">
<jsp:forward page="https://new.example.com"/>
</c:if>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With