More Stripes

Hi stripes users,
How can pass a data field value from JSP to my ActionBean class.
1.myPage.jsp has n fields
2.i want to be able to retrieve those values from myPage.jsp
and construst some object with in ActionBean class
Who is Participating?
thomas908Connect With a Mentor Commented:
Are these value form fields?
If Yes and each field has only value associated with it then you'll have to do

String field1 = request.getParameter("field1");
String field2 = request.getParameter("field2");

If teach field can have multiple values (like a checkbox) then
String []field1 = request.getParameterValues("field1");

Will the array of string be helpful?

String[] nameOfComponent;

anumalasConnect With a Mentor Commented:

You can do in the following way.

public class YourForm {

ActionBean aBean = new ActionBean();
// some other variables;
// getter and setters of your actionbean;

public class ActionBean{

// your n number of variables and their getter and setters;

public class YourAction(.......){

yourform.getActionBean().setXX(); // set your values in your actionbean using setters;


In your jsp

<bean:define id="yourForm" name="YourForm" type="com..forms.YourForm"/>
<bean:define id="actionBean" name="yourForm" property = "actionBean" />

after this to set values in n number of your fields
for eg you have to set item number in your action bean
<html:text name="yourForm" size="10" maxlength="10" property=actionBean.itemnumber"/>

after doing this in your action form your bean varibels are available in a single object.

you can retrive those values using getters like


Hope this will help :)
komlaaaAuthor Commented:
thomas, I dont thinks it is a good idea to use request.... in ActionBean class beacause, i want to be able to use JUnit to test my methods.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.