What are the diferences between JSP and Servlets?
I know that it is a nonsense for most of you, but I would be extremely obliged if you could answer.
it may seems that technically they are 'similar' since JSP are eventually compiled to servlet classes.
However, they are really different. if u are familiar with MVC pattern, u can think of JSP as the View, and Servlet as the Controller.
JSP IS FINALLY COMPILED INTO SERVLETS
BUT THERE ARE SOME ADVANTAGES
2. IMPLICIT OBJECTS
3. EASY TO USE TAGS
4.SEPERATION OF DYNAMIC CONTENT FROM PRESENTATION(LOOK AND FEEL)
. USAGE OF HTML INSIDE JAVA( XML ALSO)
BUT SERVLETS JAVA INSIDE HTML
YOU CAN DO ALMOST ALL THE THINGS WITH JSP
BUT SUN DOCUMENTS RECOMMEND SERVLETS FOR USE AS
CONTROLLER COMPONENTS FOR SERVICES LIKE
AUTHENTICATION, DATABASE VALIDATION ETC
I read some design papers recommend use Servlet as controller in MVC pattern. From my experience of doing a few B2B projects, I find that use JSP as controller is easier for writing, maintaining and modifing the code.
The major difference between a JSP and a servlet
Jsp is developed for high production demand and fexibility
so that an jsp developer need not know much about JAVA(hence Economical).
Whereas Servlet developer should be strong in Java. Internally JSP is converted into a servlet.
The basic advantage is the separation of business logic layer from the presentation layer. otherwise you can do almost anything a jsp does by using a servlet.
this helps in productivity.
you should handle the business logic in servlet and presentation in Jsp. and they should interact between themselves.