Saladin
Saladin

Reputation: 27

Saving a Struts2 Form to a Database

I'm am making a small application to teach myself Struts2 and how to use JSP.

I have a Struts2 application with a JSP page that has a struts form on it. I was wondering what would be the simplest way to submit the input data from the form to a database table that I've already created.

Can anyone show me an example or get me started?

Thanks!

Upvotes: 0

Views: 851

Answers (1)

jeff
jeff

Reputation: 4333

this is a pretty general question - there are many ways to save an object to a database. One of the most popular is using an ORM framework like Hibernate (which I see in your tags). Other ways could be using direct JDBC by turning your object into an INSERT statement.

Since you put hibernate in your tags, here's a simple example that you can follow: http://www.javaworld.com/javaworld/jw-10-2004/jw-1018-hibernate.html

The steps are - setup SessionFactory - Create a mapping for your object - use the SessionFactory to obtain a session, using session - you can save, update, etc

Just for future reference, people tend to frown on "Teach me how to do this" type posts. Good luck.

Upvotes: 2

Related Questions