

- 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 can you read a request header information in JSP?
Following is the example which uses getHeaderNames() method of HttpServletRequest to read the HTTP header information. This method returns an Enumeration that contains the header information associated with the current HTTP request.
Once we have an Enumeration, we can loop down the Enumeration in the standard manner. We will use the hasMoreElements() method to determine when to stop and the nextElement() method to get the name of 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>Header Name</th> <th>Header Value(s)</th> </tr> <% Enumeration headerNames = request.getHeaderNames(); while(headerNames.hasMoreElements()) { String paramName = (String)headerNames.nextElement(); out.print("<tr><td>" + paramName + "</td>\n"); String paramValue = request.getHeader(paramName); out.println("<td> " + paramValue + "</td></tr>\n"); } %> </table> </center> </body> </html>
- Related Questions & Answers
- How to read a HTTP header using JSP?
- How to read request parameters passed in URL using JSP?
- Which methods can be used to read HTTP header in your JSP program.
- How can you upload a file using JSP?
- How can you delete a session data in JSP?
- What is a request object in JSP?
- How to read cookies with JSP?
- How to pass more than one header in a request in Rest Assured?
- How to read a Pandas CSV file with no header?
- How to read form data using JSP?
- How to read all form parameters in JSP?
- How do you define multiple filters in JSP?
- How do you set cookies in the JSP?
- How do you implement hit counter in JSP?
- Python - Read csv file with Pandas without header?
Advertisements