You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Wim De Smet <kr...@gmail.com> on 2009/02/16 10:12:36 UTC

issues when using urlrewritefilter with struts2

Hi all,

I hope this is the right venue for asking questions like this. If I'm
mistaken, feel free to redirect me. :-)

I'm currently working on a project where we are trying to use tuckey's
urlrewritefilter[1] v3.2.0 to rewrite urls like:
http://oursite.com/search?param1=&param2=something
to
http://oursite.com/mySearch.action?param1=&param2=something

AIUI urlrewritefilter rewrites the url, then does an internal forward.
Other filters can pick up on this if they're listening on FORWARD, so
all filters (including the struts ones) do just that. However,
something really strange is happening with the parameters when the
urlrewritefilter has been triggered, all parameters are duplicated and
separated by a comma.

So for the above URL, what the application would get is param1="," and
param2="something, something". I've already done quite a lot of work
just trying to debug this, but I have no idea where these values are
being set. I suspect the action2-filters are actually setting them as
the ParametersInterceptor just gets these out of the context and
pushes them on the stack. Any pointers on how to proceed to debug (or
if you know what I'm doing wrong, that would help too) are welcome.

All of this is with struts 2.0.14 and the spring integration plugin of
the same version.

I've included the relevant web.xml section below.

regards,
Wim

<filter-mapping>
	<filter-name>UrlRewriteFilter</filter-name>
	<url-pattern>/*</url-pattern>
	<dispatcher>REQUEST</dispatcher>
	<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter-mapping>
	<filter-name>SpringOpenEntityManagerInViewFilter</filter-name>
	<url-pattern>/*</url-pattern>
	<dispatcher>FORWARD</dispatcher>
	<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<filter-mapping>
	<filter-name>Spring Security Filter Chain Proxy</filter-name>
	<url-pattern>/*</url-pattern>
	<dispatcher>FORWARD</dispatcher>
	<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<filter-mapping>
	<filter-name>action2-cleanup</filter-name>
	<url-pattern>/*</url-pattern>
	<dispatcher>FORWARD</dispatcher>
	<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<filter-mapping>
	<filter-name>sitemesh</filter-name>
	<url-pattern>/*</url-pattern>
	<dispatcher>FORWARD</dispatcher>
	<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<filter-mapping>
	<filter-name>action2</filter-name>
	<url-pattern>/*</url-pattern>
	<dispatcher>FORWARD</dispatcher>
	<dispatcher>REQUEST</dispatcher>
</filter-mapping>

[1]: http://code.google.com/p/urlrewritefilter/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: issues when using urlrewritefilter with struts2

Posted by Andy <an...@hotmail.com>.
>From the research I have done on using URLRewrite with Struts2, it just isn't very easy to get the two working together.  I had previously used Struts 1 with URLRewrite and again it is difficult.  It seems easiest when using URLRewrite with plain old servlets..

 

Other frameworks such as Ruby on Rails and Stripes (from what I was told), incorporate the RESTful URL syntax out of box.  It would be nice to see S2 implement this one day.  The REST plugin kinda does this, sortof, but not really in a full blown approach.  In order for S2 to do this fully, S2 tags would have to be able to generate URLs RESTfully as well as break apart requests using regex, IMO.

 

Andy


 
> Date: Tue, 24 Feb 2009 10:09:44 +0100
> Subject: Re: issues when using urlrewritefilter with struts2
> From: kromagg@gmail.com
> To: user@struts.apache.org
> 
> Last time I reply to myself, honest...
> 
> On Tue, Feb 24, 2009 at 9:25 AM, Wim De Smet <kr...@gmail.com> wrote:
> > I tried rewriting without including the query string, but for some
> > reason struts then doesn't pick up on the get parameters, so if you
> > try to include them in an s:url it doesn't work. I'll try some more
> > things but I'm afraid I'll just end up having to give this up.
> 
> Turns out this particular problem was being caused by a stray '?'
> (question mark) at the end of the to part of the rule. Removing that
> solved this and now at least it works if I don't include the query
> params. Thanks all for your help.
> 
> regards,
> Wim
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Access your email online and on the go with Windows Live Hotmail.
http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_HM_AE_Access_022009

Re: issues when using urlrewritefilter with struts2

Posted by Wim De Smet <kr...@gmail.com>.
Last time I reply to myself, honest...

On Tue, Feb 24, 2009 at 9:25 AM, Wim De Smet <kr...@gmail.com> wrote:
> I tried rewriting without including the query string, but for some
> reason struts then doesn't pick up on the get parameters, so if you
> try to include them in an s:url it doesn't work. I'll try some more
> things but I'm afraid I'll just end up having to give this up.

Turns out this particular problem was being caused by a stray '?'
(question mark) at the end of the to part of the rule. Removing that
solved this and now at least it works if I don't include the query
params. Thanks all for your help.

regards,
Wim

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: issues when using urlrewritefilter with struts2

Posted by Wim De Smet <kr...@gmail.com>.
Hi,

On Thu, Feb 19, 2009 at 10:21 AM, Wim De Smet <kr...@gmail.com> wrote:
> Hi,
>
> On Wed, Feb 18, 2009 at 4:47 PM, Bill Stilwell <bi...@gmail.com> wrote:
>> It took me a while to get the rewrite rule working. I can't remember
>> if the problems were the same as yours, but the solution was to not
>> put the query parameters in the <to> but rather use <set
>> type="parameter">.
>
> So if I understand correctly you parse out every parameter (if there's
> more than one) and then use <set type="parameter"> once for every
> parameter? I'm thinking this might actually work, I'll give it a try
> soon and let you all know how it turns out.

I did some more thinking on this and some testing. First of all,
getting the parameters out of the query string will be kind of hard,
since urlrewritefilter uses regexes to match and thus I'll either be
committing to having the arguments in a certain order or I won't be
able to parse out the individual parameters, which is suboptimal at
best.

I tried rewriting without including the query string, but for some
reason struts then doesn't pick up on the get parameters, so if you
try to include them in an s:url it doesn't work. I'll try some more
things but I'm afraid I'll just end up having to give this up.

regards,
Wim

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: issues when using urlrewritefilter with struts2

Posted by Wim De Smet <kr...@gmail.com>.
Hi,

On Wed, Feb 18, 2009 at 4:47 PM, Bill Stilwell <bi...@gmail.com> wrote:
> It took me a while to get the rewrite rule working. I can't remember
> if the problems were the same as yours, but the solution was to not
> put the query parameters in the <to> but rather use <set
> type="parameter">.

So if I understand correctly you parse out every parameter (if there's
more than one) and then use <set type="parameter"> once for every
parameter? I'm thinking this might actually work, I'll give it a try
soon and let you all know how it turns out.

regards,
Wim

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: issues when using urlrewritefilter with struts2

Posted by Bill Stilwell <bi...@gmail.com>.
On Wed, Feb 18, 2009 at 1:22 AM, Wim De Smet <kr...@gmail.com> wrote:
> This only seems to happen when setting use-query-string=true in the
> filter. Since our filters rely on being able to access the query
> string it doesn't really work well when we don't include it, but at
> least the parameters get set properly. (no commas and double
> parameters)
>
> After an internal forward though, struts seems to be unable to find
> converters for Integer parameters on objects. I've sort of temporarily
> fixed it by adding a couple of fake setters that accept String values
> and do the work manually, but of course this isn't ideal.
>
> None of this makes much sense to me, is struts even supposed to be
> able to handle an internal forward? Anyone have any experience with
> combining these two pieces of software?

I'm using urlrewritefilter + struts 2.1.6 and it's working fine. I'm
rewriting URLs like:

http://example.com/us/news

to

http://example.com/news?region=us

It took me a while to get the rewrite rule working. I can't remember
if the problems were the same as yours, but the solution was to not
put the query parameters in the <to> but rather use <set
type="parameter">.

Hope this helps,
Bill

-- 
Bill Stilwell - http://www.marginalia.org/
bill.stilwell@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


ExecAndWait interceptor + stream

Posted by Francisco Exposito <fc...@hotmail.com>.
Hi,

I have to generate a report and while it is being generated I need to show a waiting page. 

My xml file has:

<action name="CrearGenerarPartes" method="crearParte" class="ads.web.action.PartesAction">
            <interceptor-ref name="defaultStack"/>
            <interceptor-ref name="execAndWait">
             </interceptor-ref>
            <result name="wait" type="tiles">tiles.irgenerarpartes.wait</result>
            <result name="success" type="stream">
                <param name="contentType">application/zip</param>
                <param name="inputName">ficheroZip</param>
                  <param name="contentDisposition">filename="partes.zip"</param>
                  <param name="bufferSize">1024</param>
            </result>
            <result name="error" type="tiles">tiles.irgenerarpartes.error</result>            
</action>

When I click on the generating button I get the waiting page and when it is finished, the download file appear, but over the waiting page. When the file is generated I want to show the initial page and then that the download file appear. Is there any way to do it?

Thanks in advance.

_________________________________________________________________
Prueba los prototipos de los Ășltimos en MSN Motor
http://motor.es.msn.com/

Re: issues when using urlrewritefilter with struts2

Posted by Wim De Smet <kr...@gmail.com>.
Hi again,

On Mon, Feb 16, 2009 at 10:12 AM, Wim De Smet <kr...@gmail.com> wrote:
> I hope this is the right venue for asking questions like this. If I'm
> mistaken, feel free to redirect me. :-)
>
> I'm currently working on a project where we are trying to use tuckey's
> urlrewritefilter[1] v3.2.0 to rewrite urls like:
> http://oursite.com/search?param1=&param2=something
> to
> http://oursite.com/mySearch.action?param1=&param2=something
>
> [...]
>
> [1]: http://code.google.com/p/urlrewritefilter/

This only seems to happen when setting use-query-string=true in the
filter. Since our filters rely on being able to access the query
string it doesn't really work well when we don't include it, but at
least the parameters get set properly. (no commas and double
parameters)

After an internal forward though, struts seems to be unable to find
converters for Integer parameters on objects. I've sort of temporarily
fixed it by adding a couple of fake setters that accept String values
and do the work manually, but of course this isn't ideal.

None of this makes much sense to me, is struts even supposed to be
able to handle an internal forward? Anyone have any experience with
combining these two pieces of software?

regards,
Wim

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org