Home Jsp getParameterNames() Method Of The Request Object

Related Tutorials


 
 

Share on Google+Share on Google+

getParameterNames() Method Of The Request Object

Advertisement
This section gives you the detailed explanation about the getParameterNames() method of the request object.

getParameterNames() Method Of The Request Object

     

This section gives you the detailed explanation about the getParameterNames() method of the request object. You will learn more about the procedure of using the getParameterNames() method of the request object. Why the method used and how to use? All the things about the getParameterNames() method is explained in this section which facilitates you for working with the method in efficient manner.

This is the method of the request object used for getting the enumeration of the attributes of the html form. These values are later retrieved through the java programming language by enumerating the retrieved enumerated data by the method of the request object.

This section provides JSP file which complete code is given below, provides the facility of getting all the attribute name of the html form. When you will submit the html form, JSP code executes and shows all the parameter name from the query string by using the method getParameterNames() of the request object.

Syntax of the method is as follows:

Enumeration e = request.getParameterNames();

Above line of the code store the retrieved data (in the enumeration form) through the getParameterNames() method of the request object to the Enumeration type variable e.

Here is the JSP code of the GetParameterNamesMethod.jsp file:

<%@page import="java.util.*" %>
<html>
	<head><title>getParameterNames() method of request object.</title>
</head>
	<body>
		<form method="post">
			<table border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td>User Name: </td>
					<td><input type="text" size="20" 
name="txtUserName" />
				</tr>
				<tr>
					<td>Password: </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>
		<%
			String ParameterNames = "";
			for(Enumeration e = request.getParameterNames();
 e.hasMoreElements(); ){
				ParameterNames = (String)e.nextElement();
				out.println(ParameterNames + "<br/>");
			}
		%>
	</body>
</html>

Output for the above code:

Download the GetParameterNamesMethod.jsp file.

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


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: December 17, 2008

Related Tutorials

Discuss: getParameterNames() Method Of The Request Object   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:1
Amit kumar
March 4, 2013
only computer

i think that your answer is better
DMCA.com