37
Servlet vs JSP
Table of Contents
In this tutorial, you’ll learn about What is JSP, Servlet vs JSP , Features of JSP, Advantages of using JSP and more.
What is JSP
JSP stands for JavaServer Pages is a Java standard technology that enables you to write dynamic, data-driven pages for your Java web applications.
- It is a server side technology.
- In this JSP tags are used to insert JAVA code into HTML pages.
- It is an advanced version of Servlet Technology.
- It is a Web based technology helps us to create dynamic and platform independent web pages.
- In this, Java code can be inserted in HTML/ XML pages or both.
- JSP is first converted into servlet by JSP container before processing the client’s request.
Servlet vs JSP
Servlet | JSP |
---|---|
Need to create a class | No need to create a class |
Inherit HttpServlet class | No need to inherit any class |
Override appropriate method | No need to override any method |
Need Web.xml file | No Need Web.xml file |
After manipulation need to recompilation or redeployment. | No need to compile |
After manipulation need to restart the server | No reed to restart the server |
Features of JSP
- Coding in JSP is easy :- As it is just adding JAVA code to HTML/XML.
- Reduction in the length of Code :- In JSP we use action tags, custom tags etc.
- Connection to Database is easier :-It is easier to connect website to database and allows to read or write data easily to the database.
- Make Interactive websites :- In this we can create dynamic web pages which helps user to interact in real time environment.
- Portable, Powerful, flexible and easy to maintain :- as these are browser and server independent.
- No Redeployment and No Re-Compilation :- It is dynamic, secure and platform independent so no need to re-compilation.
- Extension to Servlet :- as it has all features of servlets, implicit objects and custom tags.
Advantages of using JSP
- It does not require advanced knowledge of JAVA
- It is capable of handling exceptions
- Easy to use and learn
- It can tags which are easy to use and understand
- Implicit objects are there which reduces the length of code
- It is suitable for both JAVA and non JAVA programmer
Disadvantages of using JSP
- Difficult to debug for errors.
- First time access leads to wastage of time
- It’s output is HTML which lacks features.