Getting Request from Client

Getting Request from Client

Posted in : Servlet Posted on : October 30, 2010 at 6:19 PM Comments : [ 0 ]

In this tutorial you will learn how to get request patameters from client

Getting Request Parameter From Client

To get parameters from client side getParameter("") method HttpServletRequest interface is called. The argument of this method is the name of your html input box. An example is given below.


<TITLE>Getting Parameter Example</TITLE>
<BODY bgcoclor=megenta>
<form method="get" action="http://localhost:8080/param">
<table border=1>
<tr><td>Enter Your Name :</td>
<td><input type="text" name="userId" value=""></td>
<tr><td>Enter Your PassWord :</td>
<td><input type="text" name="userPassWord" value=""></td>
<tr><td><input type="submit" name="Submit" value="Submit"></td>
<td><input type="reset" name="reset" value="Refresh"></td>


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class GettingRequestFromClient extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)throws 
PrintWriter out=response.getWriter();
String userId=request.getParameter("userId");
String userPassWord=request.getParameter("userPassWord");
out.println("<body bgcolor=pink >");
out.println("<h1> Getting Parameter from User Example</h1>");
out.println("User Id is -" +userId);
out.println("User PassWord is -" + userPassWord);
public void doPost(HttpServletRequest request, HttpServletResponse response)throws 
When you run this application it will display message as shown below:


Download this example code

Go to Topic «PreviousHomeNext»

Your Comment:

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image

Tutorial Topics