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---tp18653322p18656276.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Reply via email to