Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Where do I put database calls in a Struts app?

 
mareena
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to learn how to put a web-app together using Struts.1. I have some questions about where the connectivity to the database should go.
2.Using DynaActionForm in struts.
anyone to know this please help me...
 
sreenath reddy
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See coming to DB struts has nothing to do with but its always better not to put much logic in ur a ction class so its better to isolate the DB connectivity from the action and place in any utility class

coming to DynaActionForms there is a tradeoff .....this reduces the writing of form class but now u have many IDEs which gen set and get methods and that too in the future if u need to change some field changing in xml needs restart of webserver while its not in the case of ActionForm

so u decide up on this and u can proceed
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello "feena" and welcome to the JavaRanch!

I noticed you have missed our naming policy so I'd like to ask you to drop by at My Profile and edit your display name so that it complies with the "first name and last name required" rule.

Thanks!
 
Karl Beowulph
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tend to use four java classes for almost each page.

[object]Action.java
[object]Form.java
[object]DTO.java
[object]Service.java

Where object is the general name of what you're doing.

I place all my database calls and such within the service.java file. Keeps things clean, organized, and lets me extend off of a pre-made template with all my connection information and such.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic