What is the difference between JSP and Servlet?
Answers were Sorted based on User's Feedback
Answer / pratheeka reddy
Servlets are pure java programs.here we can't use HTML.
But in JSP we use HTML,so we can use and modify the data
very easily.
Servlets are faster than JSP.bcoz while running JSP
programs it will be converted into Servlets and then
executed,so it takes more time.
Is This Answer Correct ? | 205 Yes | 74 No |
Answer / satyabrata
Both servlet and jsp are web components. But servlet is
best suited for request processing, handling the business
logic while jsp is suitable for content generating .Its
easy to include html tag in jsp rather than servlet.Also
jsp is compiled to servlet when first loaded to
webserver.So in many framework servlet act as a controller
while jsp as a view.Also implicit object and action
elements available in jsp but not in servlet.
Is This Answer Correct ? | 103 Yes | 15 No |
Answer / ranjan satapathy
Jsp is better for preparing presentation pages, while
servlet is good for request processing as it's more
difficult to write include, forward a static or dynamic url
with in out.println() ,
Jsp has also all implicit objects, we need not have to
instantiate any which is easier.
error handelling is easy in jsp isErrorPage="true"
errorPage="/page"
we need not have to bother about init(),service(),destroy
(),doGet(),doPost()in jsp.
in servlet for each time changing we have to explicitly
compile it.
Jsp automatically compiled by container when we reload the
page.
Is This Answer Correct ? | 77 Yes | 11 No |
Answer / sss
JSP is mainly used for presentation only. A JSP can only be
HttpServlet that means the only supported protocol in JSP
is HTTP. But a servlet can support any protocol like HTTP,
FTP, SMTP etc.
Is This Answer Correct ? | 22 Yes | 4 No |
Answer / ravi sekhar
Like we all know both jsp's and servlets are used in web
applications.The only difference is we have html embedded in
java code in case of servlets making use of implicit
response objects and in case of jsp's it is java code that
is embedded in html code i.e.,what we call business logic
using scriplets(<%,%>).We have different applications for
both jsp's and servlets when we talk about flexibility we
opt for jsp's.It is because in case of servlets both
business logic and presentation logic are given by the same
java file ,so any change in presentation logic wll lead to
the entire compilation of the java file and replacing the
.class file back in the servlet container.When it comes to
jsp's we have both application and presentation logic
seperated.So even if u modify the presentation logic we need
not compile or modify any content of servlet engine.We are
aware of the modern web technologies advancements every day
and more over in the competing market environment it is
necessary to modify the look and feel of the page constantly
.So we prefer jsp's rather than servlets most of the
times.I do agree that servlets finds its application in
many cases but still jsp's can do the job for us.
Is This Answer Correct ? | 18 Yes | 2 No |
Answer / y ramakrishna
A servlet and jsp's both are equal ,there could many
differences in that mainly one difference is a jsp's code
will internally convert to an servlet internally.
Also the person who use jsp's no need to know java
completely.
Is This Answer Correct ? | 30 Yes | 15 No |
Answer / gaurav
The main difference between jsp and servlet is that in
servlet we write html code in java class and in jsp we write
java code in html page.Servlet is a java class.According to
MVC(model,view,controller) pattern servlet is used as
controller while JSP is used as view.
Is This Answer Correct ? | 7 Yes | 1 No |
Answer / swetha bammidi
both servlet and JSP are same.Both are using to represent a
dynamic content to the user but their job is different.And
servlets are used for business logic whereas JSP are used for
presentation logic.If u want to present the data to the user once using servlets what you do is you put HTML with in java.if you want to present the data to the user once using JSP what you do is you put java with in HTML
Is This Answer Correct ? | 5 Yes | 1 No |
Answer / amit kharkia
1)jsp is the tag oriented where as servlet are not the tag
oriented.
2)for the servlet mpping is required where as for jsp no
mapping is required.
3)jsp files are saved by .jsp extension where as servlet
files are saved by .java extension.
4)servlets are more faster than jsp.
Is This Answer Correct ? | 6 Yes | 2 No |
What is jsp and asp?
Which directive is used in jsp custom tag?
How do we prevent browser from caching output of my jsp pages?
What is tld file?
How do I run a jsp file?
Mention the advantages of jsp over pure servlets?
what type of question will be asked in the interview in this software field?????///
What are the advantages and disadvantages of thread-safe jsp page?
What’s the difference between forward and sendredirect?
What is jsp api?
Show attributes of page directives.
When will container initialize multiple jsp/servlet objects?