Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

What is the basic difference between JSP & Servlets

  Asked By: Daryl    Date: May 05    Category: Java    Views: 7158

What is the basic difference b/w JSP & Servlets? Why did JSP
introduced when we had Servlets



5 Answers Found

Answer #1    Answered By: Benjamin Simpson     Answered On: May 05

A JSP page is "transleted" into java code which is
then compiled into a servlet. You can write a servlet
in java code and compile it yourself.

Answer #2    Answered By: Adalwen Fischer     Answered On: May 05

short answer - not a lot - jsp  compiles to a servlet.
longer answer - you would tend to use jsp when you have some (html or
other) display component
but not necessarily so, you can do anything with jsp that you can do
with a servlet and more.
jsp's do tend to be easier to find on a server
(the url doesn't have to have /servlet/ in it or be specifically mapped
to somewebapp url space)
a jsp usually lives with the html content of your webapp........

Answer #3    Answered By: Dylan Evans     Answered On: May 05

IMHO,When your page is more of HTML and less computation, then it is
better to use JSP and Vice-versa. Another advantage is, you cld use
WYSWYG editors to create JSP, I like that option as it is easy to
design pages that way.

Answer #4    Answered By: Sunil Kumar     Answered On: Aug 09

the very basic difference is
servlet-html in java
jsp-java in html

Answer #5    Answered By: Uma Rani     Answered On: Aug 30

servlet: its a java class so for every change we have to
compile the code to reflect the change.Mainly using for
writing business logics.

jsp:its a file, its automatically converted into a servlet
on deploying. We can’t compile it explicitly.the changes
will get reflect by saving the file.Its mainly used for
presentation of data.....

Didn't find what you were looking for? Find more on What is the basic difference between JSP & Servlets Or get search suggestion and latest updates.