Java program to pass values from one form to another form in JSP
There are many occasions when the programmer need to pass some value to many pages in their application. For example in a shopping cart application programmer wants that if user have logged once then until it logs out his name should be displayed on the other page of the application. So it is most frequently used in to the different applications. Here in the JSP (Java Server Pages) we can pass values by the two ways:
First, if we have to only pass values from one page to another consecutive page which is being called then we can get these values by using the implicit object request to call the method request.getAttribute("parameter name").
Second, we can pass the parameters value to many pages by making the session true for those pages and the value which is to pass must be set by the method session.setAttribute("attribute name").
In our this example program we have used both ways to pass values to different pages. Here we have created three JSP pages.
FirstForm.jsp
<%@ page language="java" session="true"%>
|
SecondForm.jsp
<%@ page language="java" session="true"%>
|
FinalResult.jsp
<%@ page language="java" session="true"%>
|
Output:

Input information into the first page and then it will be passed to the next page

Now all the information will be get at the third page and will be displayed on the FinalResult.jsp

|
Recommend the tutorial |
Ask Questions? Discuss: Pass values from form to form View All Comments
Post your Comment