what is the difference between Servlet and JSP?Advantage of
JSP over Servelt?Any concept present in JSP which we cant
implement in Servlet?
Answer Posted / farhaananwar
JSP is the extension of HttpServlet instance. JSP is
basically used for presentation and servlet is used for
bussiness logic although you use servlet for presentation
after all JSP page also boil down to jsp servlet but
presentation with servlet is realy labours and boring.
Servlet are free from Http protocol you can use
GenericServlet class as base class of your custom servlet
class to perform communication with client either in http
protocal and others but with JSP page your are married only
to HTTP protocol. JSP page provides you with set of implicit
objects that are page, request, response, session,
pageContext, config, out, application, exception (only for
error page) whereas you do not find them in servlet at your
disposal. With help of servlet you can not only use jstl
tags but also design your own custom tags which can be
classic tags, simple tag and tag file. this help you to keep
away java code from JSP page presentaion. tags are like
function call where rest of bussiness logic kept away from
main flow program this helps to keep thing unclutterd and
encouraged reusablity. use of bean with standard action and
tags are easier than the use of bean in servlet.
EL expression, EL function, tags are some new concepts
that can not be used in servlet as it is but need some hard-
coding in java lang to achieve the same.
Is This Answer Correct ? | 92 Yes | 26 No |
Post New Answer View All Answers
How will you pass values from HTML page to the servlet?
Can we get PrintWriter and ServletOutputStream both in a servlet?
Why is servlet used?
What is httpservlet class?
Hello, My project requirement is like I need to create a web page using MVC pattern. I hava a bean class, jsp page, servlet, service and dao. My jsp has two fields. One is dropdown list. The option values has to get populated from the database table. The other one is a text box and its value has to come from database table. As of now I have defined the fields in bean class, got the values from database using arraylists in dao class and I called this from service class. Can anyone please tell me the workflow of how the servlet will get this arraylist and populate the arraylist values as dropdown options in jsp page? Also I would like to know the role of bean class in MVC pattern? Thanks in advance!
What is the difference between servlet and filter?
What is pure servlet?
Can we fetch the attributes related to a servlet on a different servlet?
Why is http protocol called as a stateless protocol?
Describe servlet?
What is the difference between CGI and Servlet?
Why HttpServlet class is declared abstract?
What do you mean by session tracking?
Explain the features are in servlet 3?
What is life cycle of Servlet?