
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to read all form parameters in JSP?
Following is a generic example which uses getParameterNames() method of HttpServletRequest to read all the available form parameters. This method returns an Enumeration that contains the parameter names in an unspecified order.
Once we have an Enumeration, we can loop down the Enumeration in the standard manner, using the hasMoreElements() method to determine when to stop and using the nextElement() method to get each parameter name.
<%@ page import = "java.io.*,java.util.*" %> <html> <head> <title>HTTP Header Request Example</title> </head> <body> <center> <h2>HTTP Header Request Example</h2> <table width = "100%" border = "1" align = "center"> <tr bgcolor = "#949494"> <th>Param Name</th> <th>Param Value(s)</th> </tr> <% Enumeration paramNames = request.getParameterNames(); while(paramNames.hasMoreElements()) { String paramName = (String)paramNames.nextElement(); out.print("<tr><td>" + paramName + "</td>\n"); String paramValue = request.getHeader(paramName); out.println("<td> " + paramValue + "</td></tr>\n"); } %> </table> </center> </body> </html>
Following is the content of the Hello.htm −
<html> <body> <form action = "main.jsp" method = "POST" target = "_blank"> <input type = "checkbox" name = "maths" checked = "checked" /> Maths <input type = "checkbox" name = "physics" /> Physics <input type = "checkbox" name = "chemistry" checked = "checked" /> Chem <input type = "submit" value = "Select Subject" /> </form> </body> </html>
Now try calling JSP using the above Hello.htm; this would generate a result something like as below based on the provided input −
Reading All Form Parameters
Param Name | Param Value(s) |
---|---|
maths | on |
chemistry | on |
- Related Questions & Answers
- How to read form data using JSP?
- How to read request parameters passed in URL using JSP?
- How to read form data using JSP via GET Method?
- How to read form data using JSP via POST Method?
- How to read cookies with JSP?
- How to read a HTTP header using JSP?
- How to read all contacts in android?
- How can you read a request header information in JSP?
- How to read all the coming notifications in android?
- How to read all HTTP headers in Python CGI script?
- Which methods can be used to read HTTP header in your JSP program.
- How to create a Date object and what all parameters it include?
- How to read data from all files in a directory using Java?
- Value parameters vs Reference parameters vs Output Parameters in C#
- How to use Reference Parameters in C++?
Advertisements