I need to insert a record into a table. I do the following currently,
1)Get the values of input fields from the form of jsp(say, A)
2)Submit them to another jsp(say, B)
3)In jsp B, i use the jsp:useBean and jsp:setProperty to send the values to a bean.
4)Now I forward from jsp B, to a servlet C.
5)This servlet receives the bean and uses an ordinary java class which creates connections and
insert the members of the bean to a table in database.
Is the above correct way to do this?.
Some one here pointed out that submit to a jsp is not a proper way to go in another thread.
Does all the steps above are necessary to insert a record to a database?
Can i use a servlet instead of a jsp in step 2? Is there any equivalent for jsp:useBean and jsp:setProperty in servlets?
Any good alternatives there?
Bear Bibeault wrote:It is not proper. As pointed out, submitting to a JSP just so you can use the old-fashioned setProperties tag is just awkward.
Submit to a servlet and grab the values from the request and set them into the bean in Java code. if you would like "bean assist", check out the Jakarta commons BeanUtils project.
Thanks for replying Bear Bibeault.
I checked the commons BeanUtils project.
The setProperty method provides a way to set the properties of the one by one. But the setProperty tag allows to set all the properties at one go using attribute property="*" .
Is there any method which allows me to do the same?. Or is it the case of tradeoff between convenience of developer vs maintainability?