what is the difference between?when we write the code in
following manner?

class One extends httpservlet
{
}
and
class One extends genericservlet
{
}

Answer Posted / rajavardhan reddy k

1.GenericServlet is direct implementation of Servlet
interface.In GenericServlet the servlet lifecycle method
service() is not implemented. so it's declared as
abstract.It will be useful whenever we developing the
applications based on the protocols like FTP. even it can
be used to develop HTTP based applications.GenericServlet
is in javax.servlet package.
2.HTTPServlet is indirect implementation of Servlet
interface.HTTPServlet implements all the methods of Servlet
interface.It's specific to HTTP protocol.In these days most
of the applications are web based applications(HHTP
protocol based). so that to simplify the development work
Sun people intoduced HTTPServlet class.HTTPServlet is a
abstract class even it's implements all the abstract
methods.sun people don't want to allow to create a object
for HTTPServlet so they declared it as a abstract class.In
HTTPServlet class 2 service methods are declared.

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is webservlet?

727


How the JSP file will be executed on the Server side?

861


What are the differences between servlet context vs servlet config?

801


What’s the use of the servlet wrapper classes??

829


Write a simple servlet program to print the contents of html.

768


Why are http servlets used in programming?

734


If servlet receives multiple requests, how many objects will it create?

1050


Given the request path below, which are context path, servlet path and path info?

750


Whether we can get deadlock situation in servlets?

795


What do you mean by cgi?

708


What is httpservlet class?

738


What are the types of servlets? Explain

903


Explain the differences between jsp and servlet.

722


What is new in ServletRequest interface ? (Servlet 2.4)

767


What is context in servlet?

742