Web tier: servlets, JSP, Web frameworks: Servlet to JSP or JSP to JSP

  1. Servlet to JSP or JSP to JSP (3 messages)

    Hello all,

    I want to know the pros&cons of the two methods.

    1. JSP will receive user's input from browser, and manipulate it, and then redirect to the appropriate JSP (such as error.jsp).

    2. Servlet will receive user's input from browser, and manipulate it initially, and then redirect to the appropriate JSP (such as error.jsp) or doTransaction.jsp etc.

    What are the plus and minuses of the two methods.

    Thanks in advance,

    Threaded Messages (3)

  2. Servlet to JSP or JSP to JSP[ Go to top ]


       Ultimately, JSPs execute as servlets. That said, one can take two views of developing web apps:

       1. Application Centric
       2. Document Centric

      A web app can be put together using just a single servlet. Ugly, but it works (been there, done that, not proud of it).In other words, one can create several servlets that collectively form an application. This in MHO, is "Application Centric".

      A Web app can also be put together using several JSP pages. JSP is supposed to be more friendly to HTML content creators that are familiar with some form of scripting. Granted that this is theoretical view that oversimplifies the scripting that has to go in JSPs. This would be a "Document Centric" approach to developing applications.

      IMHO, I beleive that a combination is a better approach. I like the MVC approach and use a servlet as a controller, the model aspects being encapsulated by Java Beans (or EJBs if warranted), and the view aspect being handled by the JSPs.

      All requests are handled by a controller servlet or several controller servlets, conceivably one for each major functionality that your application must handle. The controller servlet(s) instantiate the beans that do the necessary backend work and then forwards the request to the appropriate JSP page which "uses" the bean and does the page rendering.

      The advantage of using a controller servlet rather than a JSP page is that since the intent is to provide "control" aspects to the application (IMO control=programming constructs) a straight up java program (just happens to be a servlet) is better suited. Additionally, you can take advantage of the init method to take care special initializations for you (ex: talking to a connection broker perhaps).

       There is more than one way to solve the problem. The MVC approach offers a nice seperation of layers. Just my $0.02

    Hope that helps.


  3. Servlet to JSP or JSP to JSP[ Go to top ]

    hi Raj,

    shall u provide information regarding to MVC model.

    shaik chan basha
  4. Servlet to JSP or JSP to JSP[ Go to top ]

    The MVC model is very well documented, there are several resources online that talk about it in detail. The new book "JavaServer Pages" by Hans Bergsten (o'reilly) has a chapter dedicated to this. If you prefer online resources check out:


    I am pretty sure there are others, use your favorite search engine to look for MVC architecture.