File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Changing property value of an object in session with Struts2 tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Changing property value of an object in session with Struts2 tags" Watch "Changing property value of an object in session with Struts2 tags" New topic
Author

Changing property value of an object in session with Struts2 tags

Santhosh Kg
Greenhorn

Joined: Aug 17, 2009
Posts: 8
Hi all,

Is there any struts2 tag that i can use inside a jsp,to change the property of an object in session?.

Here is my requirement.

I have an object A in session(attribute name "A") which has 2 properties say name and age.

class A{
String name;
int age;
}

I want to change A.name inside a jsp using struts2 tags.

What i want to know is,is there any tag which does the below inside a jsp(don't want to use any scriptlet),
((A)session.getAttribute("A")).setName("Santhosh");

rgds,
Santhosh.
Santhosh Kg
Greenhorn

Joined: Aug 17, 2009
Posts: 8
Should have used <jsp:setProperty> instead.
<jsp:setProperty name="A" property="name" value="adaa"/>
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

To be honest I'm not sure why you'd want to--to me it seems like that kind of functionality belongs in an action.
Santhosh Kg
Greenhorn

Joined: Aug 17, 2009
Posts: 8
Hi David,
Ya,it looks dirty ..
But the thing is,i had to toggle one property after the page is loaded.

rgds,
Santhosh.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Changing property value of an object in session with Struts2 tags
 
Similar Threads
Struts2/JQuery
Struts2 and xslt
Help on Struts2 if tag to implement logic:equal and logic:present
Pagination in Struts2
Basic Struts2 Java Function Usage