W dniu 15.05.2012 21:04, chris-c pisze:
> I'm trying to map the root of the application context "/" to an existing
> actionBean.
> The actionbean I want "/" to go to, is currently bound to "/category".
>

I've wrestled with this for some time and no solution was flexible 
enough for my needs (I need mod_rewrite-style capabilities for my CMS). 
If your webapp is the only one on the app server, you can set it as 
default etc. but it differs between servers and is not elegant imo.

I've ended up with a servlet filter, configured in my web.xml before 
Stripes filter, here's the most important part of it:

/* (C) 2009-2012 Krop s.c.    www.krop.pl */
package pl.nkrop.ec.web.servlet.filter;

import java.io.IOException;
import javax.ejb.EJBException;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import pl.nkrop.ec.ejb.exception.WrongSidException;
import pl.nkrop.ec.ejb.wrapper.LoginToken;
import pl.nkrop.ec.web.backend.Ejb;
import pl.nkrop.ec.web.context.SidHelper;
import pl.nkrop.ec.web.i18n.LocalePicker;

/**
  *
  * @author Grzegorz Krugły <g...@krop.pl>
  */
public class UrlRewritingFilter implements Filter {
     private FilterConfig filterConfig;

     @Override
     public void init(FilterConfig filterConfig) throws ServletException {
         this.filterConfig = filterConfig;
     }

     @Override
     public void doFilter(ServletRequest request, ServletResponse 
response, FilterChain chain) throws IOException, ServletException {
         HttpServletRequest req = (HttpServletRequest) request;

         // check for URL mapping
         String rewrittenUrl = Ejb.get().getUrlMapping(store, 
req.getRequestURI());

         if (rewrittenUrl == null) {
             chain.doFilter(request, response);
         } else {
             
filterConfig.getServletContext().getRequestDispatcher(rewrittenUrl).forward(request,
 
response);
             return;
         }
     }

     @Override
     public void destroy() {
         this.filterConfig = null;
     }
}


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to