Series: Subject: Topic:
Question: 415 of 2110

Advantage of servlets over JSP

Asked by: Interview Candidate | Asked on: Oct 25th, 2006
Showing Answers 1 - 7 of 7 Answers

Servlets can be executed to handle request and response objects and can run independently. Every JSP has a servlet executing behind it.

Login to rate this answer.

Answered On : 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.

Login to rate this answer.
Satish Bakde

Answered On : 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.

Login to rate this answer.

Answered On : Nov 29th, 2006

View all answers by gabriela

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.

Login to rate this answer.

Answered On : Dec 25th, 2006

jsp seperates the work of webdeveloper and designerusing custom tag

Login to rate this answer.

Answered On : 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.

Yes  1 User has rated as useful.
Login to rate this answer.

Answered On : Aug 1st, 2007

Both the technologies are server side technologies,each of them has its own advantages.The basic advantages of Servlet over JSP are1) 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

Login to rate this answer.

Give your answer:

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

Related Open Questions



twitter fb Linkedin GPlus RSS


Interview Question

 Ask Interview Question?


Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.