How JSP is different from Servlets?
JSP
Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic, platform-independent method for building Web-based applications. JSP have access to the entire family of Java APIs, including the JDBC API to access enterprise databases. It can be thought of as an extension to servlet because it provides more functionality than servlet. A JSP page consists of HTML tags and JSP tags. The JSP pages are easier to maintain than servlet because we can separate designing and development.
JSP
JSP is a collection of technologies developed by Sun Microsystems. It is used to develop web pages by inserting Java code into the HTML pages by making special JSP tags. It can consist of either HTML or XML (combination of both is also possible) with JSP Actions and commands. The full form of JSP is Java Server Pages.
Servlet
Servlet is a Java technology that is managed by a container called a servlet engine. It generates dynamic content and interacts with the client through Request and Response. Servlet extends the functionality of a web server. Though servlets can respond to many types of requests, they generally implement web containers for hosting any website on web server. Therefore, it is qualified as a server-side servlet web API.
KEY DIFFERENCES
- Servlet can accept all protocol requests, including HTTP, while JSP can only accept HTTP requests.
- In MVC architecture, servlet works as a controller while JSP works as a view for displaying output.
- Servlet should be used when there is more data processing involved whereas, JSP is generally used when there is less involvement of data processing.
- Servlets run faster than JSP, on the other hand JSP runs slower than servlet as it takes time to compile the program and convert into servlets.
- You can override the service() method in servlet but, in JSP, you can’t override the service() method.
- In Servlet, you have to implement both business logic and presentation logic in the single file. Whereas in JSP, business logic is split from presentation logic using JavaBeans.
OR,
Comments
Post a Comment