- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is a request object in JSP?
The request object is an instance of a javax.servlet.http.HttpServletRequest object. Each time a client requests a page, the JSP engine creates a new object to represent that request.
The request object provides methods to get HTTP header information including form data, cookies, HTTP methods, etc.
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>
"); String paramValue = request.getHeader(paramName); out.println("<td> " + paramValue + "</td></tr>
"); } %> </table> </center> </body> </html>
- Related Articles
- What is a response object in JSP?
- What is a config Object in JSP?
- What is a pageContext Object in JSP?
- What is a page object in JSP?
- What is the session Object in JSP?
- What is an application Object in JSP?
- What is an exception Object in JSP? What type of exceptions can occur in a JSP page?
- How can you read a request header information in JSP?
- What is the out implicit object in JSP?
- How to read request parameters passed in URL using JSP?
- What is the use of page object in JSP? Need an example.
- What methods of session object is used frequently in JSP and for what purpose?
- What is a page directive in JSP?
- What is a buffer attribute in JSP?
- What is a include directive in JSP?
