Results 1 to 8 of 8
Thread: How to use <s:param> tag
- 01-11-2010, 09:05 PM #1
Member
- Join Date
- Dec 2009
- Posts
- 24
- Rep Power
- 0
How to use <s:param> tag
I need to pass a parameter from JSP to Action class in a struts 2 project.
In the JSP , I have
The ImageAction class has getId and setId method. The id value is set when I pass the integer directly in JSP, i.e.Java Code:id=1; img src="<s:url action="imgAction"><s:param name="id" value="%{id}" /></s:url>but when I provideJava Code:img src="<s:url action="imgAction"><s:param name="id" value="1" /></s:url>
, it is not set, what is the correct syntax to provide in the VALUE?Java Code:value=%{id}
I cannot provide integer directly as it changes depending on the query.
- 01-12-2010, 08:05 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Is "id" actually set somewhere for the JSP to use it?
- 01-12-2010, 02:22 PM #3
Member
- Join Date
- Dec 2009
- Posts
- 24
- Rep Power
- 0
I get id's from an sql query. I am retrieving them in a list and need to pass them one by one to the action class. How to set them so that I can pass them as params to the Action class?
- 01-12-2010, 02:45 PM #4
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Put them into a List in requestScope then loop through them using el (e.g c:foreach) while creating the img tags in the loop.
- 01-12-2010, 09:04 PM #5
Member
- Join Date
- Dec 2009
- Posts
- 24
- Rep Power
- 0
I am unable to pass imageId value from JSP to Action class.
This is the scenario..
I am retrieving images from Action class onto jsp using
I have to pass imageid, which should be used in the Action class to return a particular book. I am able to retrieve images but not able to pass this value to Action class. How can I achieve this?I do not have any forms in my JSP.Java Code:img src="<s:url action="imgAction">></img>
I am able to setID in Action class, if I pass an integer directly
ex:but in JSP, I haveJava Code:<s:param name="id" value="89">
These ids i kept them in a list and need to pass them one by one to the Action class and retrieve the corresponding images.Java Code:rst=stmt.executeQuery("select bookid from books_tb where category='Social and Economic' order by publish_date desc");
- 01-13-2010, 08:05 AM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
For starters, you shouldn't have db code (or any code) in your JSP. It's for display, not business logic.
That aside, r035198x has told you what you do. You should simply iterate over that List you've got using the relevant tag, then pass the integer to the value parameter.
- 01-13-2010, 08:20 AM #7
Member
- Join Date
- Dec 2009
- Location
- Germany
- Posts
- 43
- Rep Power
- 0
- 01-13-2010, 08:25 AM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Similar Threads
-
Parsing & handling of <object> and <param> tags
By Floxxx in forum AWT / SwingReplies: 1Last Post: 12-29-2009, 03:32 PM -
Javadoc - cannot compile @param tags
By jon80 in forum New To JavaReplies: 9Last Post: 05-14-2009, 08:57 AM -
jsp:param action
By Java Tip in forum Java TipReplies: 0Last Post: 12-24-2007, 10:03 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks