Home Tutorial Java Jsp The getQueryString() method of JSP

 
 

The getQueryString() method of JSP
Posted on: July 3, 2010 at 12:00 AM
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

Related Tags for The getQueryString() method of JSP:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.