When JSP compiles, internally the jsp compiler converts it to servlets and compiles servlets java file and generartes the class file. Every time it will do the same thing, so it may take several time. It may cause performance issue.
Most of the applications are created in MVC design pattern to seperate the functions of differnetcomponents and handle the complexity of applications. JSP and Servlets are the server sidecomponents which can respond to the client request.
Servlets are the basic components for request handling in Web Server. They contains pure Java code. Everything that needs to be done to generate the proper user response (which is genarally HTML code) needs to be done through coding. As a single servlet cannot respond each and every request by itself as client request varies in type (e.g. enquiry, update request, add etc) the request and response object is passed onto different servlets with little task completed by each servlet. This controlling part is easier to write in java. So Servlet is used as controller.
JSP is again a servlet which has syntax more like to HTML with java support. Whatever user is going to see as result of his request is HTML. Programmer can easily write html tags inside JSP to render html. This is very economical to change also. So all this code is written JSP which is (generally) the final link in Servlet chaining.
In simple words, Controller (servlet) has pure Java code while View (JSP) has HTML code.
Hi..
Thanks a lot for sharing the valuable information…
Get the Latest Interview questions on .net, php, java, core java, c, c++, ccna, oracle and many more….
here is the link for the latest interview questions on core java for both experienced and beginners..
core java interview questions and answers for experienced
Comment by Uday Kumar — June 17, 2011 @ 8:15 pm