You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Deep Blue Li <de...@gmail.com> on 2007/04/19 08:13:26 UTC

How to get original query string after more than two forwards

Hi,

I'm currently using an app. server that is using servlet 2.4. I cannot get
the original query string after doing more than two request forward.

Here is the scenario:
1. Enter the URL in the browser : http://xxx/xxx.do?search=abc
2. Go to validator, validation failed
3. Validator forwards the request to "xxx.do"  (first forward)
4. Inside xxx.do action, I can still get the query string from
request.getAttribute ("javax.servlet.forward.query_string")
5. xxx.do forward to xxx.jsp (second forward)
6. I couldn't get back the query string "search=abc" in xxx.jsp

I have tried using both request.getAttribute ("
javax.servlet.forward.query_string")  and request.getQueryString() in step
6, but both are not working.

Is there any kind soul who can help me?

Thanks!

Regards,
Deep Blue

Re: How to get original query string after more than two forwards

Posted by Lance <la...@marketpipe.com>.
Oh, and another thing, it looks like your action is redirecting to your 
jsp instead of forwarding. In struts config, remove the redirect="true" 
from your forward. With redirect = true, any request attributes you set 
in your action will not make it to your jsp, also request scoped forms 
won't work. By changing this, request.getQueryString()  will work as you 
expect in your jsp so you may not need a filter after all.

Lance.

Lance wrote:
> You could implement a javax.servlet.Filter that is mapped to *.do that 
> pushes and pops to a session based stack.
>
> Deep Blue Li wrote:
>> Hi,
>>
>> I'm using the way now, but just wonder if is there anyway I can do it 
>> using
>> serlvet API. Thanks!
>>
>> Regards,
>> Deep Blue
>>
>>
>> On 4/19/07, piloupy GOTTAPIL <b7...@yopmail.com> wrote:
>>>
>>> One trick that can help you, is to create a variable (a bean) in an
>>> action Struts, so that it can be used in the jsp file.
>>>
>>> In step 4/5 (in the action struts), you can set :
>>>
>>> request.setAttribute("myQuery", request.getQueryString());
>>>
>>> And in your jsp file, you can use it, for example, like this :
>>>
>>> <bean:write name="myQuery" />
>>>
>>> I'm not perfectly sure that it works, but you can try it.
>>>
>>> piloupy
>>>
>>> On 4/19/07, Deep Blue Li <de...@gmail.com> wrote:
>>> > Hi,
>>> >
>>> > I'm currently using an app. server that is using servlet 2.4. I 
>>> cannot
>>> get
>>> > the original query string after doing more than two request forward.
>>> >
>>> > Here is the scenario:
>>> > 1. Enter the URL in the browser : http://xxx/xxx.do?search=abc
>>> > 2. Go to validator, validation failed
>>> > 3. Validator forwards the request to "xxx.do"  (first forward)
>>> > 4. Inside xxx.do action, I can still get the query string from
>>> > request.getAttribute ("javax.servlet.forward.query_string")
>>> > 5. xxx.do forward to xxx.jsp (second forward)
>>> > 6. I couldn't get back the query string "search=abc" in xxx.jsp
>>> >
>>> > I have tried using both request.getAttribute ("
>>> > javax.servlet.forward.query_string")  and request.getQueryString() in
>>> step
>>> > 6, but both are not working.
>>> >
>>> > Is there any kind soul who can help me?
>>> >
>>> > Thanks!
>>> >
>>> > Regards,
>>> > Deep Blue
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


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


Re: How to get original query string after more than two forwards

Posted by Lance <la...@marketpipe.com>.
You could implement a javax.servlet.Filter that is mapped to *.do that 
pushes and pops to a session based stack.

Deep Blue Li wrote:
> Hi,
>
> I'm using the way now, but just wonder if is there anyway I can do it 
> using
> serlvet API. Thanks!
>
> Regards,
> Deep Blue
>
>
> On 4/19/07, piloupy GOTTAPIL <b7...@yopmail.com> wrote:
>>
>> One trick that can help you, is to create a variable (a bean) in an
>> action Struts, so that it can be used in the jsp file.
>>
>> In step 4/5 (in the action struts), you can set :
>>
>> request.setAttribute("myQuery", request.getQueryString());
>>
>> And in your jsp file, you can use it, for example, like this :
>>
>> <bean:write name="myQuery" />
>>
>> I'm not perfectly sure that it works, but you can try it.
>>
>> piloupy
>>
>> On 4/19/07, Deep Blue Li <de...@gmail.com> wrote:
>> > Hi,
>> >
>> > I'm currently using an app. server that is using servlet 2.4. I cannot
>> get
>> > the original query string after doing more than two request forward.
>> >
>> > Here is the scenario:
>> > 1. Enter the URL in the browser : http://xxx/xxx.do?search=abc
>> > 2. Go to validator, validation failed
>> > 3. Validator forwards the request to "xxx.do"  (first forward)
>> > 4. Inside xxx.do action, I can still get the query string from
>> > request.getAttribute ("javax.servlet.forward.query_string")
>> > 5. xxx.do forward to xxx.jsp (second forward)
>> > 6. I couldn't get back the query string "search=abc" in xxx.jsp
>> >
>> > I have tried using both request.getAttribute ("
>> > javax.servlet.forward.query_string")  and request.getQueryString() in
>> step
>> > 6, but both are not working.
>> >
>> > Is there any kind soul who can help me?
>> >
>> > Thanks!
>> >
>> > Regards,
>> > Deep Blue
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>


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


Re: How to get original query string after more than two forwards

Posted by Deep Blue Li <de...@gmail.com>.
Hi,

I'm using the way now, but just wonder if is there anyway I can do it using
serlvet API. Thanks!

Regards,
Deep Blue


On 4/19/07, piloupy GOTTAPIL <b7...@yopmail.com> wrote:
>
> One trick that can help you, is to create a variable (a bean) in an
> action Struts, so that it can be used in the jsp file.
>
> In step 4/5 (in the action struts), you can set :
>
> request.setAttribute("myQuery", request.getQueryString());
>
> And in your jsp file, you can use it, for example, like this :
>
> <bean:write name="myQuery" />
>
> I'm not perfectly sure that it works, but you can try it.
>
> piloupy
>
> On 4/19/07, Deep Blue Li <de...@gmail.com> wrote:
> > Hi,
> >
> > I'm currently using an app. server that is using servlet 2.4. I cannot
> get
> > the original query string after doing more than two request forward.
> >
> > Here is the scenario:
> > 1. Enter the URL in the browser : http://xxx/xxx.do?search=abc
> > 2. Go to validator, validation failed
> > 3. Validator forwards the request to "xxx.do"  (first forward)
> > 4. Inside xxx.do action, I can still get the query string from
> > request.getAttribute ("javax.servlet.forward.query_string")
> > 5. xxx.do forward to xxx.jsp (second forward)
> > 6. I couldn't get back the query string "search=abc" in xxx.jsp
> >
> > I have tried using both request.getAttribute ("
> > javax.servlet.forward.query_string")  and request.getQueryString() in
> step
> > 6, but both are not working.
> >
> > Is there any kind soul who can help me?
> >
> > Thanks!
> >
> > Regards,
> > Deep Blue
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: How to get original query string after more than two forwards

Posted by piloupy GOTTAPIL <b7...@yopmail.com>.
One trick that can help you, is to create a variable (a bean) in an
action Struts, so that it can be used in the jsp file.

In step 4/5 (in the action struts), you can set :

request.setAttribute("myQuery", request.getQueryString());

And in your jsp file, you can use it, for example, like this :

<bean:write name="myQuery" />

I'm not perfectly sure that it works, but you can try it.

piloupy

On 4/19/07, Deep Blue Li <de...@gmail.com> wrote:
> Hi,
>
> I'm currently using an app. server that is using servlet 2.4. I cannot get
> the original query string after doing more than two request forward.
>
> Here is the scenario:
> 1. Enter the URL in the browser : http://xxx/xxx.do?search=abc
> 2. Go to validator, validation failed
> 3. Validator forwards the request to "xxx.do"  (first forward)
> 4. Inside xxx.do action, I can still get the query string from
> request.getAttribute ("javax.servlet.forward.query_string")
> 5. xxx.do forward to xxx.jsp (second forward)
> 6. I couldn't get back the query string "search=abc" in xxx.jsp
>
> I have tried using both request.getAttribute ("
> javax.servlet.forward.query_string")  and request.getQueryString() in step
> 6, but both are not working.
>
> Is there any kind soul who can help me?
>
> Thanks!
>
> Regards,
> Deep Blue
>

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