You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Vinay Agarwal <Vi...@hotmail.com> on 2006/07/21 19:13:25 UTC

Redirect: Restoring Request Attributes

Hello,

 

My investigation of why my error messages (in request) are getting lost
during redirect, leads me to suspect that the request attribute restore code
may not be working as desired. Of  course, I may have totally misunderstood
it J. 

 

The way the code restores the request attributes is by copying them into
session attribute "_REQ_ATTR_MAP_". These attributes are put back into
request after redirection in two places, ContextFilter.java (130) and
RequestHandler.java (295). 

 

When a user request a url that will result in redirection, the traced steps
are as follows:

1.      ContextFilter (130),  session attribute "_REQ_ATTR_MAP_"  is null

2.      Code stores request attributes to session attribute "_REQ_ATTR_MAP_"
before calling response.sendRedirect

3.      RequestHandler (295), session attribute "_REQ_ATTR_MAP_" contains
all attributes

4.      Attributes are copied to request object correctly and session
attribute "_REQ_ATTR_MAP_" is set to null

5.      ContextFilter (130),  session attribute "_REQ_ATTR_MAP_"  is null
and request object does not contain any attributes copied in step 4.

6.      RequestHandler (295), session attribute "_REQ_ATTR_MAP_" contains
all attributes and request object does not contain any attributes copied in
step 4.

 

As seen from steps 5 and 6, all request attributes copied in step 4 are
lost. I would appreciate any help in resolving it. Thanks in advance.

 

Regards,

Vinay Agarwal

 


RE: Redirect: Restoring Request Attributes

Posted by Vinay Agarwal <Vi...@hotmail.com>.
Si, David,

After further investigation, the issue I was facing (of lost request
attributes) is a side effect of calling response.sendRedirect from within
the event handler. This does not happen when the requests are chained.

In this light, how dangerous is calling the sendRedirect from event handler?
Is it likely to cause a lot of problems?
	
Regards,
Vinay Agarwal


-----Original Message-----
From: Si Chen [mailto:sichen@opensourcestrategies.com] 
Sent: Friday, July 21, 2006 11:31 AM
To: ofbiz-dev@incubator.apache.org
Subject: Re: Redirect: Restoring Request Attributes

Ok, do you have a simplified version of what you're using so we could
replicate it?

Si


On Jul 21, 2006, at 11:25 AM, Vinay Agarwal wrote:

> error which wasn't displayed. Ordermgr quickship uses redirect which 
> might


Re: Redirect: Restoring Request Attributes

Posted by Si Chen <si...@opensourcestrategies.com>.
Ok, do you have a simplified version of what you're using so we could  
replicate it?

Si


On Jul 21, 2006, at 11:25 AM, Vinay Agarwal wrote:

> error which wasn't displayed. Ordermgr quickship uses redirect  
> which might


RE: Redirect: Restoring Request Attributes

Posted by Vinay Agarwal <Vi...@hotmail.com>.
Si,

I haven't yet thought of a way to see the attributes getting lost in the SVN
code. I was able to see it in my code because I used redirect and forced an
error which wasn't displayed. Ordermgr quickship uses redirect which might
show this problem also.

Anyway, I tried the obvious solution (commenting out the restore attribute
code in RequestHandler.java) and it does show the error that I wasn't able
to see before. I don't yet know if it breaks anything.

Regards,
Vinay Agarwal


-----Original Message-----
From: Si Chen [mailto:sichen@opensourcestrategies.com] 
Sent: Friday, July 21, 2006 10:17 AM
To: ofbiz-dev@incubator.apache.org
Subject: Re: Redirect: Restoring Request Attributes

How do I replicate this bug you are reporting?

I am hoping that might solve the "Service invocation error: commit
transaction failed" error messages as well, by the way, so I'd be happy to
look through this with you.

Si


On Jul 21, 2006, at 10:13 AM, Vinay Agarwal wrote:

> Hello,
>
>
>
> My investigation of why my error messages (in request) are getting 
> lost during redirect, leads me to suspect that the request attribute 
> restore code may not be working as desired. Of  course, I may have 
> totally misunderstood it J.
>
>
>
> The way the code restores the request attributes is by copying them 
> into session attribute "_REQ_ATTR_MAP_". These attributes are put back 
> into request after redirection in two places, ContextFilter.java (130) 
> and RequestHandler.java (295).
>
>
>
> When a user request a url that will result in redirection, the traced 
> steps are as follows:
>
> 1.      ContextFilter (130),  session attribute "_REQ_ATTR_MAP_"   
> is null
>
> 2.      Code stores request attributes to session attribute  
> "_REQ_ATTR_MAP_"
> before calling response.sendRedirect
>
> 3.      RequestHandler (295), session attribute "_REQ_ATTR_MAP_"  
> contains
> all attributes
>
> 4.      Attributes are copied to request object correctly and session
> attribute "_REQ_ATTR_MAP_" is set to null
>
> 5.      ContextFilter (130),  session attribute "_REQ_ATTR_MAP_"   
> is null
> and request object does not contain any attributes copied in step 4.
>
> 6.      RequestHandler (295), session attribute "_REQ_ATTR_MAP_"  
> contains
> all attributes and request object does not contain any attributes 
> copied in step 4.
>
>
>
> As seen from steps 5 and 6, all request attributes copied in step 4 
> are lost. I would appreciate any help in resolving it. Thanks in 
> advance.
>
>
>
> Regards,
>
> Vinay Agarwal
>
>
>


Re: Redirect: Restoring Request Attributes

Posted by Si Chen <si...@opensourcestrategies.com>.
How do I replicate this bug you are reporting?

I am hoping that might solve the "Service invocation error: commit  
transaction failed" error messages as well, by the way, so I'd be  
happy to look through this with you.

Si


On Jul 21, 2006, at 10:13 AM, Vinay Agarwal wrote:

> Hello,
>
>
>
> My investigation of why my error messages (in request) are getting  
> lost
> during redirect, leads me to suspect that the request attribute  
> restore code
> may not be working as desired. Of  course, I may have totally  
> misunderstood
> it J.
>
>
>
> The way the code restores the request attributes is by copying them  
> into
> session attribute "_REQ_ATTR_MAP_". These attributes are put back into
> request after redirection in two places, ContextFilter.java (130) and
> RequestHandler.java (295).
>
>
>
> When a user request a url that will result in redirection, the  
> traced steps
> are as follows:
>
> 1.      ContextFilter (130),  session attribute "_REQ_ATTR_MAP_"   
> is null
>
> 2.      Code stores request attributes to session attribute  
> "_REQ_ATTR_MAP_"
> before calling response.sendRedirect
>
> 3.      RequestHandler (295), session attribute "_REQ_ATTR_MAP_"  
> contains
> all attributes
>
> 4.      Attributes are copied to request object correctly and session
> attribute "_REQ_ATTR_MAP_" is set to null
>
> 5.      ContextFilter (130),  session attribute "_REQ_ATTR_MAP_"   
> is null
> and request object does not contain any attributes copied in step 4.
>
> 6.      RequestHandler (295), session attribute "_REQ_ATTR_MAP_"  
> contains
> all attributes and request object does not contain any attributes  
> copied in
> step 4.
>
>
>
> As seen from steps 5 and 6, all request attributes copied in step 4  
> are
> lost. I would appreciate any help in resolving it. Thanks in advance.
>
>
>
> Regards,
>
> Vinay Agarwal
>
>
>