Pr.Pg Next Pg

Reading Form Data using JSP tutorials

  • Depending on situation JSP uses below different method for parsing form data.

getInputStream()

  • Use for reading the binary data coming from client.

getParameter()

  • Returns the value of a request parameter as a String, or null if the parameter does not exist. request parameters are extra information sent with the request.

getParameterValues()

  • Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.

getParameterNames()

  • Returns an Enumeration of String objects containing the names of the parameters contained in this request. If the request has no parameters, the method returns an empty Enumeration.


 

JSP Program for Form Processing using URL

Sam Sir

<%-- URLdata.jsp --%>

<%-- JSP Program for Form Processing using URL --%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>URL Data</title>

</head>

<body>

<center><h3>Form Get Data using URL</h3></center>

<table>

<tr>

<td> <b>First Name:</b> </td>

<td><%= request.getParameter("First_Name")%> </td>

</tr>

<tr>

<td> <b>Last Name:</b></td>

<td> <%= request.getParameter("Last_Name")%> </td>

</tr>

<tr>

<td> <b>Sex:</b></td>

<td> <%=request.getParameter("Sex")%></td>

</tr>

</table>

</body>

</html>

Output

 

Note: Pass the following URL:

  • http://localhost:8080/JSP/URLdata.jsp?First_Name=Rahul&Last_Name=Dev&Sex=Male in the browser after URLdata.jsp compilation.

Pr.Pg border                                              Next Pg