Lavanya,
On 5/10/24 06:03, lavanya tech wrote:
If we create new java.filter as below then we can redirect the urls ?
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebFilter("/*")
public class UrlRedirectionFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;
String requestUrl = httpRequest.getRequestURL().toString();
// Check if the request URL matches the target URL
if (requestUrl.equals("https://example.lbg.com")) {
// Perform redirect to the desired destination URL
httpResponse.sendRedirect("https://server.lbg.com/towl");
This is the exact opposite of the stated goal.
You said you wanted server.lbg.com/towl to be redirected to
example.lbg.com/ but this does the opposite.
I also wouldn't both to check the protocol. Let's save this until after
the ROOT application is working as expected.
-chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org