JavaRanch Home    
 
This page:         last edited 01 April 2008         What's Changed?         Edit

Jsp Or Servlets   

Even though JSPs are based upon Servlet technology, that does not mean that they are interchangable. It also doesn't mean that they are competing technologies.

Rather, both of JSPs and Servlets have their place in a well-structured web application.

So the question never is really "JSP or Servlets", because the answer is "JSP and Servlets".

In a properly structured web application servlets will be used for control (the 'C' part of MVC) and JSPs to render the views (the 'V' part).

For more information, search for the terms MVC and "Model 2" with respect to web applications. Also, this Javaranch Journal article explains the evolution of modern best practices with regards to web application structure.

Also note that there are some things JSPs can't do, e.g. generate (or stream) binary content. For those, servlets must be used.


JspFaq

JavaRanchContact us — Copyright © 1998-2014 Paul Wheaton