aspose file tools*
The moose likes Struts and the fly likes Data from Action Class to JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Data from Action Class to JSP" Watch "Data from Action Class to JSP" New topic
Author

Data from Action Class to JSP

Aggarwal Arpit
Ranch Hand

Joined: Mar 04, 2012
Posts: 86
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

Joined: May 25, 2009
Posts: 296

Please TellTheDetails


Thanks & Regards, Sumeet
SCJP 1.4, SCWCD 5, LinkedIn Profile
Aggarwal Arpit
Ranch Hand

Joined: Mar 04, 2012
Posts: 86
I am having id=5 in my Action class that I want to display on jsp page
Jinal Prakas Shah
Ranch Hand

Joined: Jun 20, 2012
Posts: 39
define getters and setter for that particular variable and then use the <S:property > tag to display it.
Aggarwal Arpit
Ranch Hand

Joined: Mar 04, 2012
Posts: 86
I am using Struts 1. Will this work?
Jinal Prakas Shah
Ranch Hand

Joined: Jun 20, 2012
Posts: 39
Sorry Arpit it won't work in Struts1. You need to use <bean:message> tag instead.
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

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.


Have Fun with Java
little,little.. little by little makes a lot..
Aggarwal Arpit
Ranch Hand

Joined: Mar 04, 2012
Posts: 86
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

Joined: Feb 02, 2012
Posts: 21
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

Joined: Mar 04, 2012
Posts: 86
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

Joined: Jan 30, 2011
Posts: 329

Don't your Action Class have a Form bean? Why would you unnecessarily put something in session for one time use?
Aniket Khadke
Greenhorn

Joined: Jul 13, 2011
Posts: 29

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....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Data from Action Class to JSP