This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data from Action Class to JSP

 
Aggarwal Arpit
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want some data on my JSP page which is present in my Action class.
How can I send that in Struts 1?

Thanks in Advance,
Arpit
 
Sumit Patil
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please TellTheDetails
 
Aggarwal Arpit
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having id=5 in my Action class that I want to display on jsp page
 
Jinal Prakas Shah
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
define getters and setter for that particular variable and then use the <S:property > tag to display it.
 
Aggarwal Arpit
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Struts 1. Will this work?
 
Jinal Prakas Shah
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Arpit it won't work in Struts1. You need to use <bean:message> tag instead.
 
Shankar Tanikella
Ranch Hand
Posts: 329
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it is <bean:write />

Hi Aggarwal,
There are good number of tutorials available. Try them out first and it should be very easy.
 
Aggarwal Arpit
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used request.setAttribute(" "," ");
in my Action Class and used <bean:write > in my jsp to display value.But this time my jsp page is not loading.
 
Sachin Yewale
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use

in Action class and then in JSp page retrive from request attribute in scriptlets
and then use that varible in anywhere in Jsp page.


 
Aggarwal Arpit
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I done the same thing, but it's not working.
Anyways now I used session.setAttribute() in my Action class and session.getAttribute() in my JSP page and it's working fine..
 
Shankar Tanikella
Ranch Hand
Posts: 329
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't your Action Class have a Form bean? Why would you unnecessarily put something in session for one time use?
 
Aniket Khadke
Greenhorn
Posts: 29
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arpit, your action will have a form bean associted with it right? just declare i in form bean and set it in your action class. In jsp use <bean:write> tag.
it should work....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic