Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Where to store data so that 2 JSP's can access it

 
Aniket Khadke
Greenhorn
Posts: 29
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am working on a school mgmt project. In one module when user clicks a link I want to display all admissions from DB. I am invoking a action class when link is clicked bt nt getting where to store the results I got from DB, so that another JSP should also access it. Any help is welcome.

Thanks is advance
 
Jinal Prakas Shah
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It quite simple. So let's suppose you want to store a String data. Here is How you can

Now in your jsp if you are using Struts 2 you can write this tag and it will work


I don't remember for Struts1 but I think it's bean:write or bean:message.

So the main thing is understand this thing very clearly. Struts works on Java beans. So create the beans you want to access and it can be directly used in the JSP.

Regards
 
Sreehari Pillai
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can create a bean as specified above and in struts-config.xml, specify scope="session". Then you can share the data which will persist through out the session
 
Aniket Khadke
Greenhorn
Posts: 29
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jinal,Shreehari & Bear. I tried the code and it is working fine. Bear, I will make sure this won't happen again.

Thanks once again
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic