• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Structuring Java Web Application

 
Newton Windt
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, Im wanting to know what is the best ay to structure a java web application. The way I have set up my web app is i have client(which is composed of jsp pages) and server(which is a webservice to the client that has all the methods that get called from the client to access the database). What is the best way to separate the java code in the jsp pages(in the client) from the html but i still want to use jsp so that i can add some java code where needed? Is this a good way of doing it?

 
Tim Holloway
Saloon Keeper
Pie
Posts: 17989
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The accepted paradigm for J(2)EE web applications is the Model/View/Controller architecture. The View is typically a JSP or some similar form of page layout template. The Model is usually contained in one or more JavaBeans. The Controller is usually also contained in JavaBeans.

For industrial-scale projects, often a framework is used to reduce the amount of work needed by supplying pre-designed (and pre-debugged!) functionality. Popular frameworks include JSF, Struts, Tapestry and Spring-web. You might want to look at this: http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks#Java_2

For those with smaller projects, bigger egos, or legacy systems to support, you can always roll your own. So if you want to forgo a framework, the "useBean" JSP tag will quickly become your best friend. You can find plenty of documentation on useBean in any basic J2EE book covering JSPs.
 
saurabh jee
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use MVC.
The basic idea while implementing is to put all your web service method calls in a java class.After getting the data through service call,put them into a DTO(java bean) and put it in request scope.
The data that you show on JSP will come from java bean retrieved in jsp from the request scope.
To implement the MVC you may use some framework of your choice per convenience,if you feel its necessary
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic