That is all well in good, but one of the lines of code provided:

"response.sendRedirect(target);"

Is clearly an HTTP Redirect signaled to the client browser which should have
the behavior I describe and explain the loss of request attributes.  It does
not appear that the request control-flow is using the OFBIZ request control
that you describe.  Just look at how ProductSearchSession.search is defined. 
It is very much like a Struts ActionServlet.

Brad


BJ Freeman wrote:
> 
> each module ie Accounting is a container
> also the Control interface is part of ofbiz not TomCat.
> so you use a return string of "success" and it is processed by the
> control.mxl for the request map that issued the process.
>         <response name="success" type="view" value="category"/>
> 
> bplies sent the following on 7/25/2008 10:30 AM:
>> IIRC regarding servlet containers such as Tomcat (which is embedded into
>> OFBIZ).  Is that if you send a redirect, then the client browser makes a
>> *new* HttpRequest for the redirect URL.  So any attributes you store in
>> the
>> previous HttpRequest context are lost because they are not included in
>> the
>> new context.
>> 
>> Either:
>> 1.  Do not use redirect but simply serve the correct content.
>> 2.  Use the Session context instead (and be sure to cleanup after
>> yourself)
>> 
>> Brad
>> 
>> 
>> Grant Edwards-2 wrote:
>>> Hi,
>>>
>>> According to the request-map below the redirect will be to the category 
>>> view. This view is defined as part of the OFBiz ecommerce project. One 
>>> of the many scripts run by this view is categorydetail.bsh. I have added 
>>> the following lines to this script, but by all accounts something is 
>>> lacking, most probably knowledge.
>>>
>>> Can someone please explain to me why my request attribute 
>>> (otaHotelAvailRSDocument) is getting lost.
>>>
>>> <request-map uri="otasearch">
>>>         <security https="false" auth="false"/>
>>>         <event type="java" 
>>> path="com.gat.search.service.product.ota.ProductSearchSession" 
>>> invoke="search"/>
>>>         <response name="success" type="view" value="category"/>
>>>         <response name="none" type="none" value=""/>
>>>     </request-map>
>>>
>>>
>>> ProductSearchSession.search(HttpServletRequest request, 
>>> HttpServletResponse response) {
>>>       .......
>>>       request.setAttribute("otaHotelAvailRSDocument", 
>>> otaHotelAvailRSDocument);
>>>       .........
>>>       String requestName = "/category/~category_id=" + categoryId;
>>>       String target = rh.makeLink(request, response, requestName, false, 
>>> false, false);
>>>       ........
>>>       try {
>>>           response.sendRedirect(target);
>>>           return "none";
>>>       } catch (IOException e) {
>>>           Debug.logError(e, "Could not send redirect to: " + target, 
>>> module);
>>>       }
>>>
>>> }
>>>
>>>
>>>
>>> categorydetail.bsh --->
>>>
>>>
>>> otaHotelAvailRSDocument =
>>> request.getAttribute("otaHotelAvailRSDocument");
>>>
>>> if (otaHotelAvailRSDocument == null) {
>>>     System.out.println("---request----> otaHotelAvailRSDocument is 
>>> NULL");   
>>> } else {
>>>     System.out.println("---request----> otaHotelAvailRSDocument is NOT 
>>> NULL");
>>> }
>>>
>>>
>>>
>>>
>>> ---request----> otaHotelAvailRSDocument is NULL
>>>
>>>
>>> Kind regards
>>>
>>> Grant Edwards
>>>
>>>
>> 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/request-attribute-goes-missing---tp18653322p18656737.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Reply via email to