Plz any body tell me why use jsp over servlet.what is the
benefit of jsp over servlet?

Answers were Sorted based on User's Feedback



Plz any body tell me why use jsp over servlet.what is the benefit of jsp over servlet?..

Answer / guest

if any changes in jsp file need not compile every time. just
save the jsp page and refresh the browser page.
but in servlet we need compile and deploy and run again.

Is This Answer Correct ?    28 Yes 2 No

Plz any body tell me why use jsp over servlet.what is the benefit of jsp over servlet?..

Answer / tarik makhija

From a coding point of view if we want to send some text as
response back to client browser

The Servlet way is:
response.write("<p>hello</P>");

The JSP is:
<p>hello</P>
------------------------------------------------------------
JavaServer Pages (JSP) is a Java technology that allows
software developers to create dynamically-generated web
sites, with HTML, XML, or other document types, in response
to a Web client request.

So Sending information to clients without manipulating it
JSP is best i.e sending same output to every user of your
web applcation. JSP is used to Present the [ HTML/XML
output ] to user also called Presenation Logic.

Example : Users A, B, C enter wrong password while logging
to an application they will be shown same Message as JSP
Page Output: "Invalid Username/Password entered by the
user".

Since Here Output for each user is same so JSP is used.
------------------------------------------------------------
But for doing serious computations on data before (ie
Business logic) sending the respone back Servlets are best.

Servlets are used when you want to do some processing on
data submitted by the user, For example : Computing Income
Tax for a particular user based on criteria selected by the
user.

Income Tax computation result for a User A having Income 2
Lakhs per year will be different from User B having Income
5 Lakhs. So here we will use Servlet to compute the Income
Tax.


This allows for isolation of Business logic[Computing
Income Tax] from Presentation logic[Showing same message -
"Invalid Username/Password entered by the user"].

------------------------------------------------------------
Performance JSP vs Servlet :
JSP`s are internally compiled into Servlet code by JSP
Compiler. So If a request is mde to JSP page from Browser
for the first time JSP page will take more time to load
into the browser as it will be first compiled into a
servlet and then that [JSP converted Servlet] will be
executed.
Next time you request the same JSP page it will load faster
as it is already converted to servlet so servlet code will
execute then.
------------------------------------------------------------
Application Server Re-Start :

Servlets :
If Some Change is made in Servlet code then Application
Server on which servlet runs require to be re-started so as
to reflect the new change to the users of the application.

JSP : There is no need to re-start the Application Server
if JSP code change is made.
------------------------------------------------------------

Is This Answer Correct ?    18 Yes 1 No

Plz any body tell me why use jsp over servlet.what is the benefit of jsp over servlet?..

Answer / pratique suhane

Servlets means HTML within JAVA.But JSP means JAVA within
HTML.It's easy to write java within html rather than html
within java.

Is This Answer Correct ?    18 Yes 7 No

Plz any body tell me why use jsp over servlet.what is the benefit of jsp over servlet?..

Answer / taufeeq

JSP is a text based document that is used to write the code
in java language and any other scripting language like HTML.
We can develop the dynamic Webpages through the JSP
technology.

Servlet is used as a server side applet that works on
the server and recieves the client request through server
andafter process this request send the responce as the
result to the client through the server.
Servlet Does not use any scripting language.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More JSP Interview Questions

What are the elements of a jsp page?

0 Answers  


What are context initialization parameters?

0 Answers  


What are the implicit objects in jsp?

0 Answers  


How to find the hidden answers present in an online exam?

3 Answers  


How does response sendredirect work?

0 Answers  






How can we disable el?

0 Answers  


How to get value from java to jsp page?

0 Answers  


Hi, I've applied for HPCL(Information System Officer)& UIIC (A).Plz send me previous/sample papers and any suggestions regarding this exam.Please advice me good study material or related links. Thanks in advance shyam shyamprasad71@gmail.com

0 Answers  


What is session tracking in jsp?

0 Answers  


What is the difference between server side and client side programming?

0 Answers  


How many messaging models do jms provide for and what are they?

0 Answers  


What is error page in jsp?

0 Answers  


Categories