Re: [Stripes-users] Mapping Root of Web App to an Action using Dynamic Mappings
W dniu 15.05.2012 22:43, Cristian C pisze: Have you seen http://www.tuckey.org/urlrewrite/ Yeah, I have. Perhaps it's NIH syndrome, but I didn't want to learn to customize it, own filter seemed a quicker solution. It does pretty much what your filter does and much more. My problem is that even with that, I Can't map / If I add a / I get startup errors.. It seems that once the app is initialized it tries to retrieve /,.. I really don't understand why yet but it causes a stack overflow. Sorry, I didn't think of that. When I deploy to Glassfish, I can set the context path in its deployment form and / works there... So I'm still totally out of ideas how to map / to an action mapped to @UrlBinding.. Only @UrlBinding(/) worked but it invokes the bean unwantedly.. I wonder if this is a bug?.. It's not a bug, someone explained it on this newsgroup before, AFAIR it's because Stripes matches URLs as the longest matching substring or something ;-) -- 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
Re: [Stripes-users] Mapping Root of Web App to an Action using Dynamic Mappings
I figured out what was happening. It was matching actionbean for / when requesting /favicon.ico thus running it every time. I wasn't expecting this behaviour from the URL matcher. It matches very loosely and it's hard to control what I want matched. I thought /{bar} should match /favicon.ico, but / should not. Looks like it matches if the requested URL has the prefix as one of the Url Bindings. Do you think it's possible to change the behaviour by using a customized NameBasedActionResolver ? I think this is a pretty basic functionality and surprised it's so hard to achieve. It would've been really amazing if stripes had an annotation for the welcome ActionBean. :) On Wed, May 16, 2012 at 6:49 AM, Grzegorz Krugły g...@karko.net wrote: W dniu 15.05.2012 22:43, Cristian C pisze: Have you seen http://www.tuckey.org/urlrewrite/ Yeah, I have. Perhaps it's NIH syndrome, but I didn't want to learn to customize it, own filter seemed a quicker solution. It does pretty much what your filter does and much more. My problem is that even with that, I Can't map / If I add a / I get startup errors.. It seems that once the app is initialized it tries to retrieve /,.. I really don't understand why yet but it causes a stack overflow. Sorry, I didn't think of that. When I deploy to Glassfish, I can set the context path in its deployment form and / works there... So I'm still totally out of ideas how to map / to an action mapped to @UrlBinding.. Only @UrlBinding(/) worked but it invokes the bean unwantedly.. I wonder if this is a bug?.. It's not a bug, someone explained it on this newsgroup before, AFAIR it's because Stripes matches URLs as the longest matching substring or something ;-) -- 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 -- 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
Re: [Stripes-users] Mapping Root of Web App to an Action using Dynamic Mappings
W dniu 16.05.2012 16:32, Cristian C pisze: I thought /{bar} should match /favicon.ico, but / should not. Looks like it matches if the requested URL has the prefix as one of the Url Bindings. I've searched past discussion about this issue and found the ticket - http://www.stripesframework.org/jira/browse/STS-688 Do you think it's possible to change the behaviour by using a customized NameBasedActionResolver ? Probably. Never felt the need to do so, because my source of problems was really to deploy at / -- if my app gets requests to / at all, I can handle it from there with my UrlRewritingFilter :-) I think this is a pretty basic functionality and surprised it's so hard to achieve. It would've been really amazing if stripes had an annotation for the welcome ActionBean. :) The simple, recommended in past threads, solution to this is to have index.jsp forward to some action, or to use /someaction as welcome page (from what I read in the past discussion it is at least supported in Tomcat). I don't think a separate annotation is really needed, but I would like UrlBinding(/) to work as people expect -- and that means changing how URLs are matched (see STS-688 ticket I linked) at least for / -- 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
Re: [Stripes-users] Mapping Root of Web App to an Action using Dynamic Mappings
Hi, You can add this kind of code in your action bean to fake a 404 until the bug is solved. if (!context.getRequest().getServletPath().equals(/)) { return new ErrorResolution(HttpServletResponse.SC_NOT_FOUND); } Christian -Message d'origine- De : gshegosh [mailto:g...@karko.net] Envoyé : May-16-12 10:52 AM À : Stripes Users List Objet : Re: [Stripes-users] Mapping Root of Web App to an Action using Dynamic Mappings W dniu 16.05.2012 16:32, Cristian C pisze: I thought /{bar} should match /favicon.ico, but / should not. Looks like it matches if the requested URL has the prefix as one of the Url Bindings. I've searched past discussion about this issue and found the ticket - http://www.stripesframework.org/jira/browse/STS-688 Do you think it's possible to change the behaviour by using a customized NameBasedActionResolver ? Probably. Never felt the need to do so, because my source of problems was really to deploy at / -- if my app gets requests to / at all, I can handle it from there with my UrlRewritingFilter :-) I think this is a pretty basic functionality and surprised it's so hard to achieve. It would've been really amazing if stripes had an annotation for the welcome ActionBean. :) The simple, recommended in past threads, solution to this is to have index.jsp forward to some action, or to use /someaction as welcome page (from what I read in the past discussion it is at least supported in Tomcat). I don't think a separate annotation is really needed, but I would like UrlBinding(/) to work as people expect -- and that means changing how URLs are matched (see STS-688 ticket I linked) at least for / -- 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 -- 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
[Stripes-users] Mapping Root of Web App to an Action using Dynamic Mappings
Hello, I'm using DynamicMappingFilter and annotated URLs for all my actions. 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 created a new IndexActionBean which Forwards to CategoryActionBean, and placed @UrlBinding(/) on the IndexActionBean, but while debugging I found that it is being invoked simultaneously with other actions: for example if I go to /category/1 , it invokes the IndexActionBean and CategoryActionBean at once. The correct output is returned to the browser, but both actions run, which is strange. I tried to set it as a welcome file, but it doesn't seem to work with the MappingFilter. So doing this doesn't work: welcome-file/category/welcome-file I also tried with servlet mapping to *.action welcome-file-list welcome-fileIndex.action/welcome-file /welcome-file-list This makes / point to IndexActionBean and it works, but all other UrlBindings stop working.. so going to /category gives 404 not found if I set that welcome-file. Does anyone have any suggestions how I can achieve this? Thanks! -- View this message in context: http://old.nabble.com/Mapping-Root-of-Web-App-to-an-Action-using-Dynamic-Mappings-tp33850648p33850648.html Sent from the stripes-users mailing list archive at Nabble.com. -- 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
Re: [Stripes-users] Mapping Root of Web App to an Action using Dynamic Mappings
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
Re: [Stripes-users] Mapping Root of Web App to an Action using Dynamic Mappings
Hi Christian, Can't you just write an index.jsp file that forwards to your main action ? Cheers Remi 2012/5/15 Cristian C ottersl...@gmail.com Grzegorz, Have you seen http://www.tuckey.org/urlrewrite/ It does pretty much what your filter does and much more. My problem is that even with that, I Can't map / If I add a / I get startup errors.. It seems that once the app is initialized it tries to retrieve /,.. I really don't understand why yet but it causes a stack overflow. I can successfully map anything else to any stripes .action, but I can't map to any Dynamic mappings though. I mapped index.html to category.action. I also figured the problem with the welcome-file thing. It's appending the welcome file to all Dynamic Mappings/clean URL's.. so if I have /category/1 with the welcome file I get /category/1 + whatever the welcome file is. like /category/1index.html So I'm still totally out of ideas how to map / to an action mapped to @UrlBinding.. Only @UrlBinding(/) worked but it invokes the bean unwantedly.. I wonder if this is a bug?.. On Tue, May 15, 2012 at 4:01 PM, Grzegorz Krugły g...@karko.net wrote: store -- 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 -- 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
Re: [Stripes-users] Mapping Root of Web App to an Action using Dynamic Mappings
Hi, Yes that worked, I added this in the index.jsp jsp:include page=/category/ And I already had dispatcher INCLUDE defined in web.xml for the filter. I hope going through the JSP doesn't add much overhead. thanks! VANKEISBELCK Remi-2 wrote: Hi Christian, Can't you just write an index.jsp file that forwards to your main action ? Cheers Remi 2012/5/15 Cristian C ottersl...@gmail.com Grzegorz, Have you seen http://www.tuckey.org/urlrewrite/ It does pretty much what your filter does and much more. My problem is that even with that, I Can't map / If I add a / I get startup errors.. It seems that once the app is initialized it tries to retrieve /,.. I really don't understand why yet but it causes a stack overflow. I can successfully map anything else to any stripes .action, but I can't map to any Dynamic mappings though. I mapped index.html to category.action. I also figured the problem with the welcome-file thing. It's appending the welcome file to all Dynamic Mappings/clean URL's.. so if I have /category/1 with the welcome file I get /category/1 + whatever the welcome file is. like /category/1index.html So I'm still totally out of ideas how to map / to an action mapped to @UrlBinding.. Only @UrlBinding(/) worked but it invokes the bean unwantedly.. I wonder if this is a bug?.. On Tue, May 15, 2012 at 4:01 PM, Grzegorz Krugły g...@karko.net wrote: store -- 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 -- 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 -- View this message in context: http://old.nabble.com/Mapping-Root-of-Web-App-to-an-Action-using-Dynamic-Mappings-tp33850648p33855480.html Sent from the stripes-users mailing list archive at Nabble.com. -- 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