It's not a secret anymore!
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

Structuring Java Web Application

Newton Windt

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: 17410

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:

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.

An IDE is no substitute for an Intelligent Developer.
saurabh jee

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
I agree. Here's the link:
subject: Structuring Java Web Application
It's not a secret anymore!