Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Accessing struts form value in JSP

 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • 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: 40198
816
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • 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
  • 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!
 
Nothing? Or something? Like this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic