This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Because for view/display you need to have mix/embed your java output with HTML tags.and doing this in servlet means you have to write lot of out.printlns.And in JSP you can effectively use java code with html tags.Thats why we use JSPs for view.
JSP is Java code embedded in HTML; the Java code is compiled (if necessary) and run by the container on the server and the client only sees the results of that code's execution mixed in appropriately with the html.
Servlets are compiled pure Java class files (not mixed with HTML) that get posts from the client and send html to in return.
Both require a container on the server, such as Tomcat, which provides the environment and VM for the Java program.
Well JSP is for the "view " because most of the web application the changes are done at the client side and if suppose "Servlet" is used instead of the "JSP". Then the change would take so much time (Coding +compiling + deploying again in web server). This is not effiecient as a result the JSP is responsible to change simultaneously at the client end.
That is why the JSP is works as a "View" and "servlet works as a controller. Although the "JSP" is automatically converted into the servlet but automatically.
This post seems to infer that JSP is processed on the client. This is not the case. JSP is a server-side technology just as servlets are. In fact, JSPs are translated into servlets.
Perhaps this article would be helpful in understanding how JSPs work.
JSP is the preferred technology for view rendition not because it is a client-side technology (it is not), but because it is a better tool for the job. In the same way that a servlet controller is the better tool for non-view processing.