What is the recommended, "best" architecture for JSP applications?

Christopher Longo

There really is no "best" architecture. It depends on:

  1. The size and scope of the application.
  2. The amount of resources (human and monetary) available to develop the application.
  3. Time available to develop the application.

For a relatively small application which requires simple database access, a three-tier model using JSP, JavaBeans, and JDBC is all that you need. The JavaBeans would contain methods to access the data via JDBC. The JSP pages would embed the JavaBeans in the page using the <jsp:useBean> tag.

If the use of the application grows, you can always add database pooling and other optimizations to scale the architecture without redesigning everything.

If your application is going to going to be large scale - an online e-commerce site for instance, you would want to invest in a more scalable solution. I would recommend a "n-tier" solution using JSP, (standard) JavaBeans, and Enterprise JavaBeans.

JSP would provide the client interface. One or more JavaBeans would sit between the JSP pages and the EJB container. The JavaBeans would be embedded in your JSP pages using the <jsp:useBean> tag. The JavaBeans would utilize session beans to perform transactions and access data on entity beans.

This architecture is both distributed and scaleable. It supports transactions and all the benefits an application server has to offer (database pooling, clustering, etc).

Never throw JDBC code or EJB code directly on your JSP page. This leads to clutter which most web designers (the people who have to work with on the page) would probably not understand and would rather not look at. Not to mention it quickly becomes a maintenance nightmare.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact