Difference between JSP and Servlets - TechDoko

Hot

Post Top Ad

Difference between JSP and Servlets

Before I talk about the difference between JSP and Servlets, first of all I would like to talk about what is JSP and what is Servlets. JSP is Java Server Page which is the extension of Servlets. I will discuss about the Servlets in next paragraph. JSP simplify the delivery of dynamic Web content. Web applications programmer can create dynamic content by using the predefined components available in JSP and by interacting with components using server-side scripting.

Now, as talking about Servlets, they are the simply Java programs and they are also capable of creating dynamic web content. Servlets execute on the server side of a Web connection and they also extends the Web server's functionality; i.e. they extends the capabilities of servers that host applications. Those applications can be accessed via a request-response programming model.

Finally, I would like to present a short differences between JSP and Servlets. JSP is a webpage scripting language that can generate dynamic content where as Servlets are the Java programs that are already compiled which also create dynamic web content. JSP executes or run slower compared to Servlets as it takes time to convert JSP to Servlets but unlike JSP, Servlets run faster. Coding is easier in JSP but it's not so easy to write code in Servlets. In Model View Controller (MVC) pattern, JSP act as a view where as Servlets act as a controller. However, JSP is preferred if there is not much processing of data is required but in this case Servlets can handel much huge request/response processing and manipulation. JSP also has advantages, one of the best advantage of JSP over Servlets is that we can define custom tags which can be use to call Java Beans. But there is no concept of custom tags in Servlets. By running JavaScript in client side, we can achieve functionality of JSP but there is no such methods for Servelts.

No comments:

Post a Comment