You can send request parameters straight into a a bean, without scripting: The html code:
<form action="TestBean.jsp">
name: <input type="text" name="userName">
ID#: <input type="text" name="userID">
<input type="submit">
</form>
Inside TestBean.jsp:
<jsp:useBean id="person" type="foo.Person" class="foo.Employee">
<jsp:setProperty name="person" property="name" param="userName">
Note that param attribute: the param value comes from the name attribute of the form input field.
It can be simplified further, though I don’t know if that is a good idea, by following some conventions:
// abstract class foo.Person
String getName();
void setName();
// foo.Employee extends foo.Person
int getEmpID()
void setEmpID(int)
Now the HTML needs to be (basically BOTH parameters matches the property name of the bean):
<form ...>
name: <input type="text" name="name">
ID#$: <input type="text" name="empID">
...
</form>
Then we get to do this:
<jsp:useBean ... >
<jsp:setProperty name="person" property="*" />
Note that only String and primitives are converted automatically.