Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Request header display in a jsp page 
 

This is detailed jsp code that shows how to display request header information in a jsp page. When user request to the server, the request defines an object to provide client request information to a jsp.

 

Request header display in a jsp page

                         

This is detailed jsp code that shows how to display request header information in a jsp page. When user request to the server, the request defines an object to provide client request information to a jsp. In this example, request_header_jsp.jsp is used to display header information on the page. Request object's getMethod() method returns request method type i.e. GET or POST and getHeaderNames() method returns header names as an enumeration which can be iterated to get each of them.

request_header_jsp.jsp

<HTML>
<HEAD>
    <TITLE>Information about request header</TITLE>
</HEAD>
<BODY bgcolor="#ffffcc">
  <font size="+3" color="green"><br>Welcome in www.roseindia.net !</font>
  <font size="+2" color="#7E354D"><br>Information about request header</font>
  <br>
    <TABLE style="background-color: #ECE5B6;" WIDTH="30%" border="1">
	<tr>
	    <th>method used to send request</th>
	     <!-- getMethod() returns the name of the HTTP 
method with which this request was made,
	     for example, GET, POST, or PUT -->
	     <td><%= request.getMethod() %></td>
	</tr>
	<tr>
	    <th>URI of the request</th>
	    <!-- getRequestURI() returns the part of this request's URL -->
	    <td><%= request.getRequestURI() %></td>
	</tr>
	<%
	 /*This method returns an enumeration of all the header names this 
          request contains.*/	    
         java.util.Enumeration names = request.getHeaderNames();
         while (names.hasMoreElements()) {
	 String hname = (String)names.nextElement();
	%>
	<tr>
	    <th> <%= hname %> </th>
		<!-- This method returns the value of the 
specified request header as a String. -->
		<td><%= request.getHeader(hname) %></td>
	</tr>
   <%
        }
   %>
 </body> 
</html>

Save this code as a .jsp file named "request_header_jsp.jsp" in your application directory in Tomcat , 'user' for this example, and run this jsp page with url http://localhost:8080/user/request_header_jsp.jsp in address bar of the browser.

Download Source Code

                         

» View all related tutorials
Related Tags: java html c web jsp dynamic static script servlet sed ip page tag this log tar close js start technology

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.