This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

database with struts 2 !

 
nik klaus
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm new to struts , but I 'am supposed to migrate(redevelop) to struts a web application for school.The application is based on servlets, database,javascript,jsp .The first problem that I can't tackle myself is how am I going to use the database in struts. In the old application I have a class that builds the database,if it hasn't already been build and functions that manipulate the data. I used an instance of this class in the servlet to perform various tasks, but I don't know how should the database in the various classes that will implement the actions.So what strategies are there available ? (if possible without using other technologies )
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Struts doesn't dictate what back-end one can use, so you're pretty much free to do whatever you want. What you have sounds like a typical Data Access Object. There shouldn't be any problem using such a thing with Struts.
 
André-John Mas
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be separating your project in two: the model and the viewer. Typically you would have a service that encapsulates the access to the data and then you struts front-end would make use of that service to access the data.

I have found the using Spring Persistence in addition to Struts works well, since you hand off the opening and closing of databases session to Spring.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic