Difference Between Servlet and JSP

Google Advertisements

Prev Tutorial Next Tutorial

Difference Between Servlet And JSP

When we need Servlet and JSP ?

For hug request processing logic with less response generation logic we need Servlet

With less request processing logic with more response generation logic we need JSP.

Problem with Servlet

If any changes in static html code of Servlet, the entire Servlet need recompilation, redeployment, needs server restart.

Any modification in Servlet needs recompilation because both request processing logic and response generation logic are tight coupled.

Difference Between Servlet and JSP

difference between servlet and jsp
1Servlet is faster than jspJSP is slower than Servlet because it first translate into java code then compile.
2In Servlet, if we modify the code then we need recompilation, reloading, restarting the server> It means it is time consuming process.In JSP, if we do any modifications then just we need to click on refresh button and recompilation, reloading, restart the server is not required.
3Servlet is a java code.JSP is tag based approach.
4In Servlet, there is no such method for running JavaScript at client side.In JSP, we can use the client side validations using running the JavaScript at client side.
5To run a Servlet you have to make an entry of Servlet mapping into the deployment descriptor file i.e. web.xml file externally.For running a JSP there is no need to make an entry of Servlet mapping into the web.xml file externally, you may or not make an entry for JSP file as welcome file list.
6Coding of Servlet is harden than jsp.Coding of jsp is easier than Servlet because it is tag based.
7In MVC pattern, Servlet plays a controller role.In MVC pattern, JSP is used for showing output data i.e. in MVC it is a view.
8Servlet accept all protocol request.JSP will accept only http protocol request.
9In Servlet, aervice() method need to override.In JSP no need to override service() method.
10In Servlet, by default session management is not enabled we need to enable explicitly.In JSP, session management is automatically enabled.
11In Servlet we do not have implicit object. It means if we want to use an object then we need to get object explicitly form the servlet.In JSP, we have implicit object support.
12In Servlet, we need to implement business logic, presentation logic combined.In JSP, we can separate the business logic from the presentation logic by uses javaBean technology.
13In Servlet, all package must be imported on top of the servlet.In JSP, package imported anywhere top, middle and bottom.

Prev Tutorial Next Tutorial

Google Advertisements

We have more than 5 Groups which have 500000+ Members and some Pages have more than 100000+ members. If you want to post your article on our website/FB Group/FB Page please contact on hitesh.xc@gmail.com or 8076671483

Buy This Ad Space @$50 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 8076671483

Path variable is set for providing path for all Java tools like java, javac, javap, javah, jar, appletviewer which are used in java programming. All these tools are available in bin folders so we set path upto bin folders.

Classpath variable is set for providing a path for predefined Java classes which is used in our application. All classes are available in lib/rt.jar so we set classpath upto lib/rt.jar.

Cloud computing is the on demand availability of computer system resources, especially data storage and computing power, without direct active management by the user.

College Projects Related to Java, AWT, C Projects for College, C++ Projects for College, Android Projects.

Download Projects

Adsense Advertisements

Buy This ads Space 8076671483

Buy This Ad Space @$120 per Month, Ad Size 300X600 Contact on: hitesh.xc@gmail.com or 8076671483