answersLogoWhite

0

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

15y ago

What else can I help you with?

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


Why doesn't a servlet have a main method in it?

A servlet does not have a main method because it is designed to run within a servlet container, such as Apache Tomcat, which manages its lifecycle. Instead of a main method, servlets implement specific methods like doGet() and doPost() to handle HTTP requests and responses. The container invokes these methods in response to client requests, allowing the servlet to focus on processing web interactions rather than standalone execution.


If Servet Inteface is implement in userdefind servlet than in what method can you write business logic?

In a user-defined servlet that implements the Servlet interface, you can write business logic primarily in the doGet() and doPost() methods. These methods handle HTTP GET and POST requests, respectively, and are where you can process input, interact with databases, and generate responses. Depending on the application’s requirements, you might also use helper methods to organize your business logic more effectively.


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.

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 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 https and http?

http is secured https is not secured


What is the difference between DNS and HTTP?

sadsgjuh


Can you deploy servlet as web service?

Yes, you can deploy a servlet as a web service. By exposing the servlet's functionalities through HTTP requests, you can create a RESTful web service that clients can interact with using standard HTTP methods like GET, POST, PUT, and DELETE. Additionally, you can also use libraries like JAX-RS or Spring to simplify the process of building and deploying web services in a servlet container. This allows clients to communicate with the servlet over the web using standard protocols.


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 applet to servlet communication?

Applet to servlet communication refers to the interaction between a Java applet running in a client’s web browser and a Java servlet running on a server. This communication typically occurs over HTTP, where the applet sends requests to the servlet to retrieve or send data, often using URL connections. The servlet processes these requests and returns responses, which the applet can then use to update its UI or perform further actions. This interaction enables dynamic web applications by allowing client-side applets to leverage server-side resources.