PlanetJava
Custom Search

java-stripes-user
[Top] [All Lists]

Re: Clean URLs - URLRewrite (forward) NPE

Subject: Re: Clean URLs - URLRewrite (forward) NPE
Date: Wed, 20 Jun 2007 10:59:00 -0400
I don't know how I missed it last time, but in both cases (yours and the 
one you referenced) it looks like DispatcherServlet.service(...) is 
being invoked without StripesFilter.doFilter(...) ever having been 
called. Make sure in your web.xml that StripesFilter is set to execute 
on REQUEST and FORWARD. Or you might be able to get away with making 
StripesFilter execute before UrlRewriteFilter instead of after on REQUEST.
-Ben
sja wrote:
> Hi,
>
> I'm trying to get Paul Tuckey's URL Rewrite Filter to work with Stripes
> (v1.4.2) without limited success. I have a 'rule' configured in my
> urlrewrite.xml file that should! forward requests any requests matching the
> url pattern specified in the 'from' element to that of the 'to' element.
> However this, the default behaviour of the simplest rule you can specify
> results in a NPE error being returned by the Stripes DispatcherServlet.
>
> The problem was subject of another thread on this forum a little while back
> (
> http://www.nabble.com/Help---NPE-in-DispatcherServlet-tf3840630.html#a10874521
> http://www.nabble.com/Help---NPE-in-DispatcherServlet-tf3840630.html#a10874521
> ), but the thread has since gone quiet without resolution as far as i can
> tell.
>
> <snip>
> java.lang.NullPointerException
>
> net.sourceforge.stripes.controller.DispatcherServlet.doOneTimeConfiguration(DispatcherServlet.java:260)
>
> net.sourceforge.stripes.controller.DispatcherServlet.doPost(DispatcherServlet.java:89)
>
> net.sourceforge.stripes.controller.DispatcherServlet.doGet(DispatcherServlet.java:61)
>       javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
>       javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>
> org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:195)
>
> org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:159)
>       org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:141)
>
> org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90)
>
> org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:406)
> </snip>
>
> Hopefully, the simplest example to illustrate my point.
>
> - this rule does not! :(-
> <rule>
>   <from>/page/([A-Za-z]+)/([0-9]+)</from>
>   <to>%{context-path}/Page.action?event=$1&id=$2</to>
> </rule>
>
> - this rule works :) -
> <rule>
>   <from>/page/([A-Za-z]+)/([0-9]+)</from>
>   <to type="redirect">%{context-path}/Page.action?event=$1&id=$2</to>
> </rule>
>
> If I explicitly declare a 'type' attribute with the value 'redirect' on the
> 'to' element of the first rule above (see second rule) everything works as
> it should and the user is redirected to the URL specified in the 'to'
> element. But i don't want the user being physically redirected as this
> defeats one of the purposes of using the URL Rewrite Filter, to hide
> complex/ugly URLs from the user by presenting/letting them use
> clean/friendly URL's that map onto/get turned into complex/ugly URLs in the
> background in a way that's invisible to the user. So what i get is this;
>
> # http://localhost:9090/contextname/page/view/23 
>  - redirects (shown to user in browser addressbar) to -
> # http://localhost:9090/contextname/app/Page.action?id=23  
>  - (view = default handler hence not specified, but could also = edit,
> update, new...., e.g.
> http://localhost:9090/contextname/app/Page.action?edit=&id=23) 
>  
> What I actually want and expect to happen using the default URL Rewrite
> Filter behaviour (= forward) is that the first 'clean' URL forwards sliently
> in the background to the second URL, such that the second URL is masked to
> the user/browser by the first so that it's never seen.
>
> I'm familiar with the Stripes Clean URL extension
> (http://remi.mongus.com/stripes-clean/) and have used it succesfully in the
> past, however it requires the addition of another dispatcher url mapping in
> apps web.xml, so urls like  # http://localhost:9090/contextname/page/view/23 
> - become -  # http://localhost:9090/contextname/app/page/view/23 . I could
> get around this minor  problem if URL Rewrite Filter / Stripes played nicely
> together, but then i wouldn't need to use the extension at all if that were
> the case and could do all i needed by configuring URL Rewrite Filter rules,
> fwding to and masking default unclean Stripes URL's. There are also other
> benefits of using the more full feature URL Rewrite Filter instead of/in
> addition to the Stripes Clean URL extension.
>
> Any help would be very much appreciated.
>
> Many thanks,
> Simon
>   
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
msgmiddle
<Prev in Thread] Current Thread [Next in Thread>
Current Sitemap | © 2012 planetjava | Contact | Privacy Policy