• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Accessing struts form value in JSP

 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

Does anyone know how to access a Struts form value in a JSP page? I'm trying to populate Struts property values (businessID & businessName) into a JSP hash map.

Here's my JSP code:

...


</head>

<body>
<html:form action="/searchDetails" name="SearchResultForm" type="org.apache.struts.validator.DynaValidatorForm">

<table width="680" height="246" border="0">
<tr>
<td colspan="2"><bean:write name="SearchResultForm" property="businessID" /></td>
</tr>
<tr>
<td colspan="2"><bean:write name="SearchResultForm" property="businessName" /
</td>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>

<jsp:useBean id="params" class="java.util.HashMap" scope="page" />
<%
params.put("request", request.getAttribute("businessID") );
params.put("businessName", request.getAttribute("businessName") );

%>

...

Please HeLP!!!
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nina,
The form is just an attribute in the request or session. You can do a jsp:useBean or request/session.getAttribute() call and then access the values.

Why do you need a HashMap in the JSP? Usually logic is done in the Action and only presentation is done in the JSP.
 
Nina Anderson
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using the Hash map to passed multiple values to the html:link struts tag.

e.g. <html:link name="params" forward="someAction">SomeName</html:html>

I tried using the request.getParameter("businessID"), but it did not work. It is not recognizing the "businessID" form variable I didn't in my struts-config.xml.

Please HeLP!
 
It will give me the powers of the gods. Not bad for a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic