Home Tutorial Java Jsp The getQueryString() method of JSP

 
 

Share on Google+Share on Google+
The getQueryString() method of JSP
Posted on: July 3, 2010 at 12:00 AM
Advertisement
In this Section, we will learn about using "getQueryString() " method to retrieve the 'query string'.

The getQueryString() method of JSP

In this Section, we will learn about using "getQueryString() " method to retrieve the 'query string'.

The "getQueryString()" method is used to fetch the 'query string'. The query string contains the attribute & the value of the html or JSP form, which sends with the POST /GET  method  to Servlet or JSP page for any request.

Example :  In this Example , we are asking user to enter any username and password string, the output displays the query string means username & password . The Query String is fetched using the method "getQueryString()".

<html>

<head><title>getQueryString() method of request object.</title></head>

<body bgcolor="purple">

<form method="get" >

<table border="0" cellspacing="0" cellpadding="0">

<tr>

<td><b><font color="white">User Name:</font></b> </td>

<td><input type="text" size="20" name="txtUserName" />

</tr>

<tr>

<td><b><font color="white">Password: </font></b></td>

<td><input type="password" size="20" name="txtPassword" />

</tr>

<tr>

<td>&nbsp;</td>

<td><input type="submit" value="Submit" name="B1" /></td>

</tr>

</table>

</form>

<font color="white">

<%

if(request.getQueryString() != null)

out.println(request.getQueryString());

%>

</font>

</body>

</html>

OUTPUT :

After Submitting Value the output should be :

Download Source Code

Advertisement

Related Tags for The getQueryString() method of JSP:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 3, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com