wood burning stoves 2.0*
The moose likes JSP and the fly likes Structuring Java Web Application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Structuring Java Web Application" Watch "Structuring Java Web Application" New topic
Author

Structuring Java Web Application

Newton Windt
Greenhorn

Joined: Mar 14, 2012
Posts: 5
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

Joined: Jun 25, 2001
Posts: 15957
    
  19

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
saurabh jee
Greenhorn

Joined: May 11, 2012
Posts: 1
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
 
Consider Paul's rocket mass heater.
 
subject: Structuring Java Web Application
 
Similar Threads
How to store a value so that any JSP page can read it?
What to use ? jsp and html or call Applet from servlet?
Converting Swing three-tier application to thin client
Test 488 questions
Web based Java project