java2db

Get Request Parameters in Servlet (get parameter name,value)



The Request Parameters comes along with the HTTP request from the client.There are different approaches given below to get request parameters in servlet .

 

Get the value of request parameters in servlet :

URL : http://localhost:8080/employeeApp/empDemo?no=3&name=rose

 

 

Get the name and value of request parameters in servlet :

Get Request Parameters in Servlet URL : http://localhost:8080/employeeApp/empDemo?no=3&name=rose&age=23

Insert the above cone in the servlet doPost(–) or service(–) method.Finally you will get all the parameter names and values in a Map having key and value pairs.

 

 

Get Request Parameters in Servlet Get the multiple values of Request Parameters in Servlet :

Get Request Parameters in Servlet URL : http://localhost:8080/employeeApp/empDemo?name=rose&name=lilly

If any request parameter have multiple values , use the below code to get all its values.

Also you can get with array index. Example :String value1 = request.getParameterValues(“name)[0];

 

 

 




Related Posts :
Kill or invalidate session using session id ( concurrent login )
Servlet Filter ( Request and Response filters in servlets ) example
URL rewriting in servlets ( Servlet session tracking )
Servlet Cookies ( Servlets session tracking with cookie )
Hidden form field in servlets ( Servlet session tracking )
Request attributes in servlet with an example ( Attribute scope )
Session attributes in servlet with example (Attribute scope)
ServletConext Attributes in servlet ( Attribute scope )
   [will not be published]



^ <