Reputation: 35276
How do I redirect a request with JSP with the path also forwarded?
Example:
my-domain.com/abc to www.other-domain.com/abc
Where 'abc' would be the request path. Also it is possible to also forward query parameters and fragment identifiers?
Upvotes: 1
Views: 199
Reputation: 16615
You can't redirect fragment identifiers as they aren't passed to the server.
To do this in JSP you'll want something like the following:
<%
response.sendRedirect("http://www.other-domain.com" +
request.getContextPath() +
request.getServletPath() +
(request.getQueryString() == null ?
"" :
"?" + request.getQueryString())
%>
Upvotes: 1