The getQueryString() method is defined in the HttpServletRequest interface, which is used to retrieve the query string of the HTTP request. A query string is the string on the URL to the right of the path to the servlet. Using this a programmer can know the data which is sent from the client(when a form is submitted) … [Read more...]
ServletResponse Interface – Servlets
The ServletResponse represents the response which is sent back to the user. The servlet container creates a ServletResponse object and passes it as an argument to the servlet's service method. … [Read more...]
ServletRequest Interface – Servlets
The ServletRequest Interface defines an object which is used to encapsulate information about the user's request, including parameter name/value pairs, attributes, and an input stream. … [Read more...]
Obtaining HTTP Request Headers from HttpServletRequest
In this article we will learn how to get the HTTP Request Headers via HttpServletRequest, The HTTP request which a client browser sends to the server includes HTTP request headers with some important information, such as cookies and the referer. You can access these headers from the HttpServletRequest object passed to a doxxx method. … [Read more...]
ServletContext Interface in Servlets
ServletContext is one of the predefined interface available in javax.servlet.* package, The object of the ServletContext is created by the web container at the time of deploying the application(which will be available one per application) . This object is used to get configuration information from web.xml file. … [Read more...]
Get Configuration information – ServletConfig
Each Servlet application allows you to configure and retrieve parameters via web.xml . You can specify initial parameter name/value pairs using <init-param> tag. In this example we will learn how to retrieve configuration information from the web.xml file. … [Read more...]
welcome-file-list in web.xml of Servlets
You could have seen the <welcome-file-list> tag in web.xml of your project and could have wondered the use of it. In this tutorial we will learn how to use this tag effectively. … [Read more...]
Difference Between GenericServlet and HttpServlet
Generic Servlet: Generic Servlet is protocol independent(i.e)it can handle all types of protocols like http, ftp, smtp etc. GenericServlet class is direct subclass of Servlet Interface. … [Read more...]
HttpServlet class
The HttpServlet class extends the GenericServlet class and implements Serializable interface. It provides all the Http protocol supported methods such as doGet(), doPost(), doHead(), doPut(), doDelete(), doOptions(), doTrace(). … [Read more...]
GenericServlet class
GenericServlet is a abstract class which is defined in the Servlet API. GenericServlet class implements Servlet, ServletConfig and Serializable interfaces, it provides implementation for all the methods of the Servlet Interface except the service() method. … [Read more...]
Servlet Interface
Servlet Interface provides the common methods which needs to be implemented by all the servlets. All the servlets must implement this interface directly or indirectly. To have the implementation of the Servlet Interface you can extend GenericServlet Class(javax.servlet.GenericServlet) or HttpServlet Class (javax.servlet.http.HttpServlet). Read through Running Your First … [Read more...]
Running Your First Servlet Application
Once we have installed and configured Tomcat, we need to follow the below five steps to run our First Hello World Application. Create a directory under Tomcat for our application. Coding our servlet. We will be using javax.servlet package and the javax.servlet.http package in our source code. Create a deployment descriptor. Compile our source code. Run Tomcat … [Read more...]