I want to set the jsp text field values in struts2 Action class automatically when i declare the fie

I don't want to declare those variables in Action class again

Employee POJO:

package com.pojo; import java.io.Serializable; public class Employee{ String name; Address address; public String getName() { return name; } public void setName(String name) { this.name = name; } public Address getAddress() { return address; } public void setAddress(Address address) { this.address = address; } }


package com.pojo; import java.io.Serializable; public class Address{ String email; public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } }


<body> <s:form action="beanEx"> <s:textfield label="name" name="name"/> <s:textfield label="email" name="email"/> <s:submit value="Submit"/> </s:form> </body>

I want to populate the values automatically set the values in Action class

Can anybody help me out........


Have two objects in your action class with getter/setter

private Address address = new Address(); private Employee employee = new Employee();;

then in your jsp do like this:

<body> <s:form action="beanEx"> <s:textfield name="employee.name" label="name"/> <s:textfield name="address.email" label="email"/> <s:submit value="Submit"/> </s:form> </body>

Basically earlier you were pointing to the field now you are pointing to the field inside an object.


  • Batch Update to Spreadsheet with Google GData API Using 2 Legged OAUTH / OPEN ID Domain Account
  • JavaFX, why is TableColumn null?
  • Sending custom HTTP request with PHP
  • Get information about customer by email id in magento
  • redirecting from admin page to a postAction on frontend
  • Android ListView with custom adapter Search not working
  • redirecting from admin page to a postAction on frontend
  • java.sql.SQLException: ORA-00917: missing comma
  • Firebase database data retrieving -Java
  • Hibernate Search Query
  • Symfony2 Form is always empty after submitting
  • Problem serializing DecimalFormatSymbols in 2.3.4
  • Single Table Inheritance in Rails 4
  • Issue with static code in Android
  • Express displaying mongodb documents in Jade
  • Delphi: Where is the shortcut that started the application? [duplicate]
  • can variables be set randomly when declaring them again?
  • Problem with rejecting incoming call
  • Validate jQuery plugin, field not required
  • Thread 1: EXC_BAD_ACCESS (code =1 address = 0x0)
  • Meteor: Do Something On Email Verification Confirmation
  • Exception “firebase.functions() takes … no argument …” when specifying a region for a Cloud Function
  • Cannot resolve symbol 'MyApi'
  • Email format validation in mvc3 view
  • How to get address from latitude and longitude android google map v2 [duplicate]
  • sending/ receiving email in Java
  • AT Commands to Send SMS not working in Windows 8.1
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • AngularJs get employee from factory
  • using HTMLImports.whenReady not working in chrome
  • apache spark aggregate function using min value
  • EntityFramework adding new object to nested object collection
  • Checking variable from a different class in C#
  • Django query for large number of relationships
  • Sorting a 2D array using the second column C++
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • How can I use `wmic` in a Windows PE script?
  • failed to connect to specific WiFi in android programmatically
  • How to push additional view controllers onto NavigationController but keep the TabBar?
  • How can I use threading to 'tick' a timer to be accessed by other threads?