Reputation: 452
Hi I have a context and i have a mapping problem with this context. When I put this to my web.xml
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
I can only access like this.
but I wanna access like this
what should I do?
Edit: I saw that when i hit for http://domain.com/sub-context in browser it redirects me to http://domain.com/sub-context/ although i havent do anything special for that. Who is doing this. Weblogic?
Upvotes: 2
Views: 754
Reputation: 11588
Here is one way:
<filter-mapping>
<filter-name>RedirectFilter</filter-name>
<url-pattern>/sub-context</url-pattern>
</filter-mapping>
Then in RedirectFilter:
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain filterChain)
throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest)req;
HttpServletResponse response = (HttpServletResponse)resp;
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
String redirectURL = "http://domain.com/sub-context/";
response.setHeader("Location", redirectURL);
}
Adapted from here: redirect through web.xml in google-app-engine
Upvotes: 1