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 Servlet API used for connecting database?

622


What are the servlet events?

600


Which exception is thrown if the servlet is not initialized properly?

600


How can the referrer and the target urls be used in servlet?

540


What is servlet in tomcat?

566






What do you mean by web applications? Explain web application directory arrangement?

548


What is the difference between sendredirect() and forward() in a servlet?

531


Explain the role of dispatcherservlet and contextloaderlistener.

614


What is meant by session? Tell me something about httpsession class?

607


What are the different session tracking techniques?

687


Explain jsessionid?

624


Write a hello world program using servlets.

597


Name the packages that work with servlet?

555


How forward () method is different from send redirect () method?

522


How servlets are deployed in java?

550