Package organization of a 3 tier web application


General J2EE: Package organization of a 3 tier web application

  1. Hi All, Can anyone tell me what is the best way of organizing my classes into packages when developing a 3 tier web application?
  2. src/org/action - Controller servlet(if you are using the struts - then you can use action servlet) - purpose - getting the HTTP request from the browser src/org/business - To handle the business logic src/org/pojo - POJO(Entity) src/org/dao - Data access layer -we can have the interface and implementation of data base accessing logic. To create the user defined exception(s). src/org/hbm - If you are using the hibernate - then you can place the all the mapping files inside this folder itself. web /jsp - You can place all the jsp inside the folder web/js - For java script web/css - For cascading style sheet web/images - We can place all the images related to the project. web/web-inf/lib - place all the jars related to the application I think, the above hints will help.
  3. Hi, Thanks for you response. Currently i am following the below structure. 1)com/appname/web/controllers - for Servlets/Struts Actions/Spring Controllers 2)com/appname/web/forms - beans for capturing and displaying user view data. Like(FormBeans/Command classes) 3)com/appname/business/services - POJOs/EJB acting as Business Objects. 4)com/appname/domain - having domain model objects. 5)com/appname/dao/impl - for DAO Interfaces and their corresponding implementation classes. 6)com/appname/utilities - for any utility classes. 7)com/appname/exceptions - having application specific exception classes. With the above approach, i have to use domain objects, exception classes have to be used across all the layers. But in future if i want to host web app in a web server and service layer on a different app server i need to place them in both places. Can you suggest whether it is fine or do i need to change my package structure. Thanks, K. Siva Prasad Reddy.
  4. Research appFuse![ Go to top ]

    You could research appFuse project,there are many best practices in it!:)