Hmm, I'm not sure I understand the question at all.
1) What version of struts are you in? Since you are referring to needing to
understand how to use Sessions I assume struts 2, since struts 1 would be
obvious, the action class has a request object you can get the session from.
2) What do you mean by 'im not using a action mapping class'?
In the case of using Sessions with Struts2 - by the way I would recommend
avoiding this - you can always implement SessionAware. Depends on what you want
to do but I have done things that don't require implementing SessionAware but
in that case I just need to have a user object out of the session. To do that I
create a base class...
public abstract class UserAwareBaseAction extends ActionSupport {
private User user;
.
.
.
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
/**
*
* Delegate to executeAction since this is an abstract class.
*
*/
public String execute() throws Exception {
return executeAction();
}
public abstract String executeAction() throws Exception;
}
Now all my classes that need a user from the session can extend this class -
and implement executeAction() (instead of execute obviously) and have the user
available. The user is set in my spring configuration...
<beans ...>
<bean id="indexAction" class="com.daugherty.action.common.IndexAction"
scope="prototype" >
<property name="user" ref="user" />
</bean>
<bean id="user" class="com.daugherty.entities.User" scope="session" />
</beans>
There is a "gotcha" to doing things this way. For instance in my login action I
cannot do something like:
User u = façade.login(username, password);
This.setUser(u);
You won't end up updating the object spring is storing for you. Instead you
would have to do a deep copy to the spring object...
User u = façade.login(username, password);
User springUser = this.getUser();
springUser.setUsername(u.getUsername());
.
.
.
And so on...
HTH,
Al
-----Original Message-----
From: mthalis [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2008 5:02 AM
To: [email protected]
Subject: session handling
I'm developping a web based application using struts. There, i need to handle
sessions and other relevant stuff. can somebody plz let me know all about
this with essential examples. I was googling and still unable to find
relavant solution. since im not using a action mapping class, it is hard to
implement it.
--
View this message in context:
http://www.nabble.com/session-handling-tp20809961p20809961.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]