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 13:51:46 -0400
Sounds like a good idea to me.
Jeppe Cramon wrote:
Ben, I was thinking. The place where we endup throwing an NPE, couldn't we
do a check for null and throw an exception explaining what you've just
explained?
/Jeppe
-----Original Message-----
From: [email protected]xxxxxxx 
[mailto:stripes-users-
[email protected]] On Behalf Of Ben 
Gunter
Sent: 20. juni 2007 16:59
To: Stripes Users List
Subject: Re: [Stripes-users] Clean URLs - URLRewrite (forward) NPE
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.doOneTimeConfiguratio
n(DispatcherServlet.java:260)
net.sourceforge.stripes.controller.DispatcherServlet.doPost(DispatcherServ
let.java:89)
net.sourceforge.stripes.controller.DispatcherServlet.doGet(DispatcherServl
et.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(NormalRewri
ttenUrl.java:195)
org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:1
59)
org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:1
41)
org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.j
ava:90)
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilt
er.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/
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users
__________ NOD32 2341 (20070620) Information __________
This message was checked by NOD32 antivirus system.
http://www.eset.com
-------------------------------------------------------------------------
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/
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users
-------------------------------------------------------------------------
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/
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users
msgmiddle
<Prev in Thread] Current Thread [Next in Thread>
Current Sitemap | © 2012 planetjava | Contact | Privacy Policy