[Struts] Problem with setAttribute and <logic:present>

A

AdSR

Hi all,

I already googled for this, but didn't get a good answer. I have the
following problem:

In my action class I do

request.setAttribute("result", result);

Then in the JSP page

<logic:present name="result">
<p>Got result</p>
</logic:present>
<% if (request.getAttribute("result") != null) { %>
<p>found attribute</p>
<% } %>

None of the test messages show. What am I doing wrong?

Relevant config excerpt:

<action
path="/calc"
type="valueadder.CalculateAction"
name="paramsForm"
scope="request"
validate="true"
unknown="true"
forward="/index.jsp"
input="/index.jsp">
</action>

TIA,

AdSR
 
A

AdSR

Wendy S said:
The DTD (http://struts.apache.org/dtds/struts-config_1_2.dtd) says that
'forward' is:
"Module-relative path of the servlet or other resource that
will process this request, instead of the Action
class specified by "type".

Try removing the 'forward' attribute.

Thanks. It worked.

In case anyone needs more info:

In addition to the above, I had to add

<forward name="success" path="/index.jsp"/>

inside action, and replace

return super.execute(mapping, form, request, response);

with

return mapping.findForward("success");

in the action class.

AdSR
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,167
Latest member
SusanaSwan
Top