Reader Level:

Getting Header Data From One JSP Page to Another

By Vikas Mishra on Jan 03 2012
In this article, I am going to describe how to get header data from one jsp page to another jsp page.
    • Like
    • Love It
    • Awesome
    • Interesting
    • It's Okay
    • Thumbs Down
  • 16.4k
  • 0

This is the next article in the series of Http Header in JSP articles. In my previous article Http Request Headers Display in a JSP page I have already described http request headers and in this article, I am going to describe how to get header data from one JSP page to another JSP page. To understand this concept we are going to develop a JSP web project with the following steps.

Step 1: Select New Project

In this step first we select the New Project option from File menu.


Step 2: Create New Web Application

In this step we select web application option from java web and click on the next button.

select new javawebapplication.jpg

Step 3: Name and Location

In this step we provide a specific name and location to the this aplication, and click on the next button.


Step 4: Select Server and setting

In this step we select a specific server and then click on the next button.

server and.jpg

Step 5: Select Framework

In this step there is no need to select any framework for this application.


Step 6: Create a JSP File

In this step we create the two jsp files index.jsp and formAction.jsp.

create new file.jpg



         <TITLE>Getting Header Data </TITLE>
       <BODY bgcolor="cyan">
          <H1>Getting Header Data From One Page</H1>
               <FORM ACTION="formAction.jsp" METHOD="POST">
               <INPUT TYPE="submit" VALUE="">



        <TITLE>Reading Header Information </TITLE>
     <BODY bgcolor="green">
        <H1>Reading Header Information From another page</H1>
               Here are the request headers and their data:
        <% java.util.Enumeration names = request.getHeaderNames();
             String name = (String) names.nextElement();
             out.println(name + ":<BR>" + request.getHeader(name) + "<BR><BR>");

Step 7: Compiling and Running the Application

Now we compile and then run it on the server and find the following output: