morsa804tons
asked on
excluding an URI from a container
hi,
i've a java app deployed at tomcat, under uri https://xxxx.com/mag (/mag/*), but i need if some user types https://xxxx.com/mag/quer, it redirects to an index.html file. How i can do that?
Thanks!
i've a java app deployed at tomcat, under uri https://xxxx.com/mag (/mag/*), but i need if some user types https://xxxx.com/mag/quer, it redirects to an index.html file. How i can do that?
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://java.sun.com/javaee/5/docs/tutorial/doc/bnagb.html
http://java.sun.com/products/servlet/Filters.html
package rrz;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class RedirectFilter implements Filter {
public void init(FilterConfig config) throws ServletException{
System.out.println("init of RedirectFilter"); // for testing
}
public void destroy(){}
public void doFilter(ServletRequest req,ServletResponse resp,FilterChain chain)
throws ServletException, IOException {
HttpServletRequest request = (HttpServletRequest)req;
String uri = request.getRequestURI();
if(uri.indexOf("whatever")
else response.sendRedirect(requ
}
}
and in your web.xml you should have something like
<filter>
<filter-name>redirectfilte
<filter-class>rrz.Redirect
</filter>
<filter-mapping>
<filter-name>redirectfilte
<url-pattern>(/mag/*</url-
</filter-mapping>