Servlet Request

The objective of a Servlet is to handle client request. There are two interfaces present in Servlet API, javax.servlet.ServletRequest and javax.servlet.http.HttpServletRequest to encapsulate client request. An object of ServletRequest is used to provide the client request information to a servlet such as content type, content length, parameter names and values, header informations, attributes etc .

Let's see an example to demonstrate the Servlet Request

    <form action="MyServlet" method="post">
        Name <input type="text" name="uname">
        <input type="submit" value="ok">
import javax.servlet.*;
import javax.servlet.http.*;

public class MyServlet extends HttpServlet {

  protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    PrintWriter pw = response.getWriter();
    String s=request.getParameter("uname");
    <servlet-name> abc</servlet-name>

About the Author

Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc