Advantage of servlets over JSP

Showing Answers 1 - 19 of 19 Answers

satyarajasekhar

  • Nov 18th, 2006
 

A servlet can handle different dynamic pages. Even if the pages to be deployed are 20 or 200, one servlet can handle. In jsp a servlet is deployed for every jsp page.

  Was this answer useful?  Yes

Satish Bakde

  • Nov 24th, 2006
 

JSPs are compiled into Servlet classes. So internally both are same.

From programmers point of view, Servlet contains pure Java code while JSP contains HTML code bundled with JSP scripting elements and JSP tags.

A Web Server checks whether a JSP is modified, if it is it translated into Servlet, it is complied and then executed like a normal Servlet.

Difference is in the syntax writing.

  Was this answer useful?  Yes

gabriela

  • Nov 29th, 2006
 

Usually JSPs mix java and html and are used for presentation/view. I rarely see a servlet containing html code(only for learning purpose) and this is because a servlet is used mainly as a controller(it encaplutates the logic of requests flow). Ofcourse JSPs are internally, pure servlets but they are used in different layers in an application.

  Was this answer useful?  Yes

karuppaiyan

  • Dec 25th, 2006
 

jsp seperates the work of webdeveloper and designer

using custom tag

  Was this answer useful?  Yes

Guest

  • Jan 5th, 2007
 

There is no advantage of servlets over jsp. Whatever servlets can do will be done by JSPs also. A JSP is ultimately a servlet. We go for JSP to seperate the bussiness logic from the presentation logic. But in servlets, we will write both bussiness logic and presentation logic together. There problems come into the picture. If we do any modification to the presentation logic, we have to re-deploy the servlet inorder to see the reuslt of modified code of the servlet. So for every time we modifing the servlet , we should re-deploy the servlet. Its very big headache.

But where as in the case of JSP, we will write presentation logic in jsp ang bussiness logic inside the java bean and we use that java bean object in our jsp page using <jsp:useBean> tag. So, even if we do any modification to the presentation logic, no need to re-deploy the jsp. It will automatically reloaded by the container.

JSP increase the productivity of the developer. ie, a developer can write more no. of jsps than the servlets with in a period of time.

But there is only a small disadvantage of jsp over servlet. JSP somewhat slower than servlet. Bcoz, while converting a jsp into a servlet, jspc(jsp compiler)generates a lot of code that really unwanted one. But if we write a servlet, we know what what we need to write and what we need not to write. So we wont write any extra code. Thatswhy manually written servlets are somewhat faster than JSPs.

Mir

  • Aug 1st, 2007
 

Both the technologies are server side technologies,each of them has its own advantages.The basic advantages of Servlet over JSP are

1) The execution time required in the servlet is lesser than, because jsp is derived from the servlet so when client makes a request first time to the specific jsp file the container will perfom three steps a)Translation b)Compilation c)construction where as in the servlet these steps are not required except construction.

2) A servlet can handle different dynamic pages where as the jsp can handle only on dynamic page

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions