answersLogoWhite

0


Best Answer

The difference is that a GenericServlet has no defined protocol (it is "generic"), while HttpServler uses the HTTP protocol. HttpServlet is a subclass of GenericServlet with the purpose of creating a servlet for a web site.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Difference between HTTP servlet and Generic servlet?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Basic Math

What is difference between GET and POST in servlets in java?

The difference between a GET and a POST is the way data is transferred to a servlet. With a GET, the URL will show each name/value pair on the query string in the URL. For example, if you had a form with a field named 'foo,' and when submitted had a value of 'bar,' the URL might be something like this: http://www.example.com/servlet?foo=bar With a POST, this information is not visible in the URL. Instead, it is transferred in the HTTP headers. As far as the actual servlet is concerned, there is not a great deal of difference when it comes to getting the parameters. Whether you use a GET or a POST, you still use request.getParameter("foo"); to get the value. The method used in the Servlet for processing either a GET or a POST is different too. If you use a GET, the method that is called is doGet(HttpServletRequest, HttpServletResponse). The doGet method is also called if there is no GET or POST data. If you use a POST, the method called is doPost(HttpServletRequest, HttpServletResponse).


What is doPost in servlet?

doPost() is the method in the servlet that is used to service the Http requests submitted using the Post option. HTML forms can be submitted in two ways using the Get method and the Post method. You can specify the method while declaring the form itself. So you will have two methods in the servlet doGet() and doPost() each for one of them


What is the difference between JSP and Servlets?

A JSP is typically oriented more towards displaying information, and a servlet is more oriented towards processing information. For example, a JSP might display a report, while a servlet would process a user submitted form. These uses are not exclusive, but they are optimized more for performing tasks in this manner. It is much easier to incorporate HTML coding into a JSP than a Servlet. It is also easier to write more complex Java code in a servlet.AnswerJSP has Implicit objects and Servlets do not. AnswerJSP and Servlet both define the server end functionality to provide dynamic outputs ,As we know our HTML is only the client end technology version which runs on client browser. JSP and Servlet differ each other in terms of represntation and execution cycle. Servlet are full functional java codes that define the output like write to stream files in protocol defined ways, JSP on the other hand is Role Sepated format to do so where a ordinary web designer designes how will be the presentation of the data and Programmer defines the functinality to provide the underlying things represented in conditional and non conditinal ways , But here is the magic of JSp that merges the both HTML represntation mixed with JAVA scriptlets. Look at http://www.jsptube.com/jsp-tutorials/jsp-introduction.html, it explains how does JSP differs from servlet.


What is servlet API in java?

Overview of the Servlet APIThe Servlet 2.3 API consists of two packages: javax.servlet and javax.servlet.http. The base functionality is defined in the javax.servlet package whose classes and interfaces outline a generic, protocol-independent implementation. This means you can use it for non-Web applications, too. Of course, the exam targets the Web, so the HTTP protocol is the only one discussed in this blog. The javax.servlet.http interface defines classes and interfaces that are specific to the Hypertext Transfer Protocol (HTTP).The javax.servlet PackageThe javax.servlet package defines 12 interfaces, 7 classes, and 2 exceptions. These interfaces, classes, and exceptions are as follows.Interfaces• Filter:- Preprocessor of the request before it reaches a servlet. It can also be a postprocessor of the response leaving a servlet. It can modify a request or response (for example, change headers), the request to a resource (a servlet or static content), or the response from a resource.• RequestDispatcher:- This is the servlet version of a redirect. It enables requests to be processed and then forwarded to other components of a Web application, such as another servlet, HTML file, or JSP file.• Servlet:- Defines the life-cycle methods that are implemented by all servlets.• ServletConfig:- This class has the methods for accessing the servlet configuration information such as the servlets name (from the web.xml file), the initialization parameters, and the ServletContext object.• ServletContext:- These methods enable your servlet to communicate with its servlet container. This is how you get the MIME type of a file, dispatch requests, or write to a log file. Notice that this information has application scope. The most important features of the ServletContext are application-scope attributes access, logging, and context initialization parameters.• ServletContextAttributeListener:- Implementations of this interface receive notifications of changes to the attribute list on the servlet context of a Web application. Supports the handling of the ServletContextAttributeEvent class.• ServletContextListener:- An interface that supports the handling of the ServletContextEvent class. Defines a set of methods that a servlet uses to communicate with its servlet container. It can get the MIME type of a file, dispatch requests, or write to a log file. Notice that there is one context per "Web application" per Java Virtual Machine. The specification defines a "Web application" as a collection of servlets and content installed under a specific subset of the server's URL namespace, such as /catalog, and possibly installed via a .war file.• ServletRequest:- This interface forms the base for the class that provides client request information to a servlet. It is protocol-independent.• ServletResponse:- This interface forms the base for the class that represents the response sent from the servlet to the client.• SingleThreadModel:- An interface that ensures a given servlet handles only one request at a time.Classes• GenericServlet:- An abstract class that implements ServletConfig. It defines a generic, protocol-independent servlet.• ServletContextAttributeEvent:- This is the event class for notifications about changes to the attributes of the servlet context of a Web application.• ServletContextEvent:- This is the event class for notifications about changes to the servlet context of a Web application (parent of ServletContextAttributeEvent).• ServletInputStream:- Provides an input stream for reading binary data from a client request. You can modify it; it already has the readLine method for reading data one line at a time.• ServletOutputStream:- An abstract class providing an output stream for sending binary data to the client. You print HTML, XML, or other output to the client using ServletOutputStream's print() and println() methods.• ServletRequestWrapper:- Provides a convenient implementation of the ServletRequest interface that can be subclassed by developers wishing to adapt the request to a Servlet. This is where you can modify the behavior of request objects.• ServletResponseWrapper:- Provides a convenient implementation of the ServletResponse interface that can be subclassed by developers wishing to adapt the response from a Servlet. This is where you can modify the behavior of response objects.Exceptions• ServletException:- Extends java.lang.Exception to provide a base class for defining servlet-related extensions.• UnavailableException:- Extends ServletException to indicate that a servlet is temporarily or permanently unavailable.The javax.servlet.http PackageThe javax.servlet.http package defines eight interfaces and seven classes. These interfaces and classes are as follows:InterfacesThe interfaces include the following:• HttpServletRequest:- Extends javax.servlet.ServletRequest to support HTTP.• HttpServletResponse:- Extends javax.servlet.ServletResponse to support HTTP.• HttpSession:- Defines methods that provide access to persistent session-state information.• HttpSessionActivationListener:- Implemented to handle the HttpSessionActivationEvent.• HttpSessionAttributeListener:- Implemented to handle the HttpSessionAttributeEvent.• HttpSessionBindingListener:- Implemented by objects that listen for HttpSessionBindingEvent events.• HttpSessionListener:- Implemented to handle the HttpSessionEvent.ClassesThe classes include the following:• Cookie:- Encapsulates HTTP cookies.• HttpServlet:- An abstract class that extends javax.servlet.GenericServlet to provide support for HTTP.• HttpServletRequestWrapper:- Provides the capability to wrap and modify incoming HttpServletRequest objects.• HttpServletResponseWrapper:- Provides the capability to wrap and modify outgoing HttpServletResponse objects.• HttpSessionBindingEvent:- Extends java.util.EventObject to define an event that is sent to an HttpSessionBindingListener when an object is bound or unbound from the current HttpSession.• HttpSessionEvent:- Parent class of HttpSessionBindingEvent.


What is difference between servlets and java server pages?

SERVLETS JSP 1. Servlet is a java class. 2. Servlet is a single instance multiple thread web application, In which HTML code can be included in java code. 3. In servlets the presentation logic and the B.logic is tightly coupled. 4. For every modification done in servlet program, we need to recompile and reload the application. 5. In servlets implicit objects are not available. 6. Servlets are supported to HTTP, FTP, and SMTP protocols. 7. Sevlets are need Deployment Descriptor file (web.xml) 1. Jsp is a file. 2. In jsp java code can be included in HTML code by using special tags. 3. In jsp's the presentation logic and B.logic are separated by defining the java beans. 4. If any modifications done in jsp's without recompiling and reloading , the modifications are reflected. 5. In jsp's implicit objects are available which is we can implement directly into jsp pages. 6. Jsp are supported to HTTP protocol only. 7. No need of Deployment Descriptor file (web.xml) rajus_1219@yahoo.co.in

Related questions

What are types of servlet?

Http servlet and Generic servlet


What is generic servlet class?

GenericServlet defines a generic, protocol-independent servlet whereas HttpServlet Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site that uses the Http Protocol.


Generic Servlet and HTTP Servlet?

javax.servlet.GenericServletSignature: public abstract class GenericServlet extends java.lang.Object implements Servlet, ServletConfig, java.io.SerializableGenericServlet defines a generic, protocol-independent servlet.GenericServlet gives a blueprint and makes writing servlet easier.GenericServlet provides simple versions of the lifecycle methods init and destroy and of the methods in the ServletConfig interface.GenericServlet implements the log method, declared in the ServletContext interface.To write a generic servlet, it is sufficient to override the abstract service method.javax.servlet.http.HttpServletSignature: public abstract class HttpServlet extends GenericServlet implements java.io.SerializableHttpServlet defines a HTTP protocol specific servlet.HttpServlet gives a blueprint for Http servlet and makes writing them easier.HttpServlet extends the GenericServlet and hence inherits the properties GenericServlet.


Can you catch a train between Montreal and New York?

sure you can: http://www.amtrak.com/servlet/ContentServer?pagename=Amtrak/HomePage


What is difference between GET and POST in servlets in java?

The difference between a GET and a POST is the way data is transferred to a servlet. With a GET, the URL will show each name/value pair on the query string in the URL. For example, if you had a form with a field named 'foo,' and when submitted had a value of 'bar,' the URL might be something like this: http://www.example.com/servlet?foo=bar With a POST, this information is not visible in the URL. Instead, it is transferred in the HTTP headers. As far as the actual servlet is concerned, there is not a great deal of difference when it comes to getting the parameters. Whether you use a GET or a POST, you still use request.getParameter("foo"); to get the value. The method used in the Servlet for processing either a GET or a POST is different too. If you use a GET, the method that is called is doGet(HttpServletRequest, HttpServletResponse). The doGet method is also called if there is no GET or POST data. If you use a POST, the method called is doPost(HttpServletRequest, HttpServletResponse).


How much is escada ocean lounge perfume?

Depends. 1 oz $24.50 http://www.scential.com/servlet/the-13524/Escada/Detail 1.7 oz $25.75 http://www.scential.com/servlet/the-11077/Escada-escada-ocean-lounge/Detail 3.4 oz $40.00 http://www.scential.com/servlet/the-3166/escada-ocean-lounge%2C-perfume%2C/Detail


What is the difference between https and http?

http is secured https is not secured


What servlet API used for database connection?

The Servlet 2.3 API consists of two packages: javax.servlet and javax.servlet.http. The base functionality is defined in the javax.servlet package whose classes and interfaces outline a generic, protocol-independent implementation. This means you can use it for non-Web applications, too. The javax.servlet.http interface defines classes and interfaces that are specific to the Hypertext Transfer Protocol (HTTP).


What is the difference between DNS and HTTP?

sadsgjuh


Where can i find Power window control switch for explorer 2002?

http://www.conquestauto.com/servlet/the-1850/2002-dsh-2002--Ford-Explorer/Detail http://www.conquestauto.com/servlet/the-1850/2002-dsh-2002--Ford-Explorer/Detail


What is the difference between DDR1 and DDR2?

http://dhivacpt.blogspot.com/2007/10/difference-between-ddr1-and-ddr2.html


What use import javaxservlethttpHttpServletRequest in java?

The Http RequestWhen a user hits a URL with a servlet at the other end, the Servlet Container creates an HttpServletRequest object. It passes this object as an argument to the servlet's service methods (doPut(), doGet(), and doPost()). There is a lot of information in this object, including the login details of the user making this request and the name of the HTTP method with which this request was made.