Ariram Kalimuthu wrote:Answer for Q1 - No (i am not sure)
Answer for Q2:
i also doing like that what you mentioned.
before that, you should configure the interceptor as default-interceptor
please do the following steps:
1). interceptor.
public String intercept(ActionInvocation actionInvocation) throws Exception {
ActionContext context = actionInvocation.getInvocationContext();
Map<String, Object> sessionMap = context.getSession();
//System.out.println(" retrived session "+ sessionMap);
if(sessionMap == null
|| sessionMap.isEmpty()
|| sessionMap.get("SESSION_SERVICE") == null) {
System.out.println(" session expired...");
return "SESSION_EXPIRED";
}
String actionResult = actionInvocation.invoke();
return actionResult;
}
SESSION_SERVICE - one of the attribute we are setting after user login.
if the session expired, session object will be null [if struts creates the session object our attribute won't be there]
2). struts.xml
<interceptors>
<interceptor name="tstSessionInterceptor" class="package.SessionInterceptor"/>
<interceptor-stack name="tstSessionCheckStack">
<interceptor-ref name="tstSessionInterceptor" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="tstSessionCheckStack"/>
</global-results>
<result name="sessionexpired" >sessionexpired.jsp</result>
</global-results>
thats what i have implemented.
it's working fine.
please revert back, if any issues.
thanks
This code is not running properly...actually i want the show the message after session time out....please help me out of this...........My LoginAction page coding is:---
package com;
import java.util.Map;
import org.apache.struts2.dispatcher.SessionMap;
import org.apache.struts2.interceptor.SessionAware;
import com.opensymphony.xwork2.ActionSupport;
public class Login extends ActionSupport implements SessionAware{
private String username,userpass;
SessionMap<String,String> sessionmap;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getUserpass() {
return userpass;
}
public void setUserpass(String userpass) {
this.userpass = userpass;
}
public String execute(){
if(LoginDao.validate(username, userpass)){
return "success";
}
else{
return "error";
}
}
public void setSession(Map map) {
sessionmap=(SessionMap)map;
sessionmap.put("login","true");
}
public String logout(){
sessionmap.invalidate();
return "success";
}
}
.......