I have two pages say one.jsp and two.jsp. tell how can transfer the whole details record from one page to other page.
one.jsp has fallow name as age records
name age
| abc | | 8 |
| xyz | | 7 |
now i want to get these details in two.jsp, please tell me how can I do that.
You have two ways to do that.
Setting attribute to session
or setting attribute to request
session.setAttribute("SomeKey",valObj);
Object attribute = session.getAttribute("SomeKey");
or
req.setAttribute("SomeKey",valObj);
Object attribute2 = req.getAttribute("SomeKey");
Do not forget to casting to your required object.
In jsp1 use this code..
session.setAttribute("user1.name","abc");
session.setAttribute("user1.age",8);
session.setAttribute("user2.name","xyz");
session.setAttribute("user2.age",7);
In jsp2 use this code..
String use1name = session.getAttribute("user1.name");
int user1age = Integer.parseInt(session.getAttribute("user1.age"));
String use2name = session.getAttribute("user2.name");
int user2age = Integer.parseInt(session.getAttribute("user2.age"));
You can also use request or application instead of session according to your use
Create another(third) column with hyperlink tag. Create a link that will look like as
<a href="secondJspPage.jsp?name=abc&age=8">link</a>
Similar link will be created for each record on first JSP page.
When you click on that link you can get value in next JSP as:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.