tags:

views:

316

answers:

2

I have a legacy Struts 1.2.8 application that I'm maintaining and porting from Oracle Application Server (OAS) 10g to JBoss 4.2.3. I have a JSP that uses the Struts HTML tag library. The JSP page is backed by EJBs. The user enters an item number and the page displays the details of the item (e.g. item from a product catalog).

On the first 3 times I use this page, the item details are returned correctly. But for some reason, on the fourth submission of the page and on subsequent submissions, some of the item information is missing. I'm using

<html:hidden property="itemNumber"/>
<html:text property="itemNumber"/>

tags. The bizarre part of this problem is that I can't recreate the problem in OAS. In addition, if I replace the above html:text tag with

<input type="text" value="<%=itemForm.getItemNumber() %>" >

The code works correctly. My guess is that this is a session/request/scope problem. But I haven't found the correct configuration.

Is there special configuration required for Struts in JBoss?

A: 

Check the scope being used for the action in the struts-config.xml file. Most likely you probably want the scope to be request.

Mr. Will
A: 

The problem was caching in the Jasper JSP engine. The default configuration is

enablePooling - Determines whether tag handler pooling is enabled. true or false, 
  default true. 

I was able to set enablePooling to false and my problem was resolved. I assume this is a bug in Jasper. This bug appeared when a JSP custom tag (e.g. html:hidden) is followed by a jsp:attribute where the name is "value". See below.

<html:hidden property="itemNumber"/>
.
.
<html:text property="regularPrice" maxlength="9" readonly="<%=disabled%>" 
    tabindex="9" onkeyup="onRegularPriceChanged(this)">
    <jsp:attribute name="value">
        <webmodules:currency onlyDisplayValue="false">
            <jsp:attribute name="currencyValue">
                <bean:write name="updateItemForm" property="regularPrice"/>
            </jsp:attribute>
        </webmodules:currency> 
     </jsp:attribute>
 </html:text>

There seems to be a namespace and caching conflict between the "value" that is set by the html:hidden and the "value" that is set by the jsp:attribute. After the JSP page was used twice the cached value set by the jsp:attribute was being used as the value for html:hidden.

Rob Wright