hi everybody.
I have following problem.
There are two pages. index.jsp and main.jsp in my application
Index.jsp contains logging interface in .
It submits password and userid to loginform bean.
following are entries in struts-config.xml file
[CODE=xml]
<action input="index.js p" name="loginform " path="/login" scope="session" type="com.myapp .struts.loginac tion">
<forward name="success" path="/main.jsp"/>
</action>
<action path="/logout" scope="session" type="com.myapp .struts.logouta ction">
<forward name="logout" path="/index.jsp"/>
</action>
[/CODE]
on successfully logged in control is forwarded to main.jsp file. On main.jsp file their is one image having logout caption . so code for it is as follows
[CODE=html]
<html:link page="/logout.do"> <img src="img/logout_deselect .jpg" name="Image11" height="30" border="0"> </html:link>
[/CODE]
Now actionforms are as follows
loginaction.jav a
[code=java]
/*
* loginaction.jav a
*
* Created on February 26, 2007, 10:48 AM
*/
package com.myapp.strut s;
import javax.servlet.h ttp.HttpServlet Request;
import javax.servlet.h ttp.HttpServlet Response;
import org.apache.stru ts.action.Actio n;
import org.apache.stru ts.action.Actio nForm;
import org.apache.stru ts.action.Actio nMapping;
import org.apache.stru ts.action.Actio nForward;
/**
*
* @author root
* @version
*/
public class loginaction extends Action {
/**
* This is the action called from the Struts framework.
* @param mapping The ActionMapping used to select this instance.
* @param form The optional ActionForm bean for this request.
* @param request The HTTP Request we are processing.
* @param response The HTTP Response we are processing.
* @throws java.lang.Excep tion
* @return
*/
public ActionForward execute(ActionM apping mapping, ActionForm form,
HttpServletRequ est request, HttpServletResp onse response)
throws Exception {
loginform lform=(com.myap p.struts.loginf orm) form;
// String uid="Welcome" + lform.getUserid ()+"";
// request.getSess ion().setAttrib ute("userName", uid);
response.setHea der("Cache-Control","no-cache"); //Forces caches to obtain a new copy of the page from the origin server
response.setHea der("Cache-Control","no-store"); //Directs caches not to store the page under any circumstance
response.setDat eHeader("Expire s", 0); //Causes the proxy cache to see the page as "stale"
response.setHea der("Pragma","n o-cache");
request.getSess ion();
request.getSess ion().setAttrib ute("loginform" ,lform);
return mapping.findFor ward("success") ;
}
}
[/code]
logoutaction.ja va is as follows
[code=java]
/*
* loginaction.jav a
*
* Created on February 26, 2007, 10:48 AM
*/
package com.myapp.strut s;
import javax.servlet.h ttp.HttpServlet Request;
import javax.servlet.h ttp.HttpServlet Response;
import org.apache.stru ts.action.Actio n;
import org.apache.stru ts.action.Actio nForm;
import org.apache.stru ts.action.Actio nMapping;
import org.apache.stru ts.action.Actio nForward;
/**
*
* @author root
* @version
*/
public class logoutaction extends Action {
/* forward name="success" path="" */
// private final static String SUCCESS = "success";
/**
* This is the action called from the Struts framework.
* @param mapping The ActionMapping used to select this instance.
* @param form The optional ActionForm bean for this request.
* @param request The HTTP Request we are processing.
* @param response The HTTP Response we are processing.
* @throws java.lang.Excep tion
* @return
*/
public ActionForward execute(ActionM apping mapping, ActionForm form,
HttpServletRequ est request, HttpServletResp onse response)
throws Exception
{
// request.getSess ion().setAttrib ute("userName", null);
request.getSess ion().removeAtt ribute("loginfo rm");
request.getSess ion().invalidat e();
return mapping.findFor ward("logout");
}
}
[/code]
So when i clicks on logout image the control is forwarded to index.jsp
But when i press backbutton of the browser the main.jsp page is displayed.
i.e. logout is not working properly.
I want functionality like when back button will be pressed "session expirred messaged should be displayed and control should be forwared to index.jsp page
Can anybody help me out with this
I have following problem.
There are two pages. index.jsp and main.jsp in my application
Index.jsp contains logging interface in .
It submits password and userid to loginform bean.
following are entries in struts-config.xml file
[CODE=xml]
<action input="index.js p" name="loginform " path="/login" scope="session" type="com.myapp .struts.loginac tion">
<forward name="success" path="/main.jsp"/>
</action>
<action path="/logout" scope="session" type="com.myapp .struts.logouta ction">
<forward name="logout" path="/index.jsp"/>
</action>
[/CODE]
on successfully logged in control is forwarded to main.jsp file. On main.jsp file their is one image having logout caption . so code for it is as follows
[CODE=html]
<html:link page="/logout.do"> <img src="img/logout_deselect .jpg" name="Image11" height="30" border="0"> </html:link>
[/CODE]
Now actionforms are as follows
loginaction.jav a
[code=java]
/*
* loginaction.jav a
*
* Created on February 26, 2007, 10:48 AM
*/
package com.myapp.strut s;
import javax.servlet.h ttp.HttpServlet Request;
import javax.servlet.h ttp.HttpServlet Response;
import org.apache.stru ts.action.Actio n;
import org.apache.stru ts.action.Actio nForm;
import org.apache.stru ts.action.Actio nMapping;
import org.apache.stru ts.action.Actio nForward;
/**
*
* @author root
* @version
*/
public class loginaction extends Action {
/**
* This is the action called from the Struts framework.
* @param mapping The ActionMapping used to select this instance.
* @param form The optional ActionForm bean for this request.
* @param request The HTTP Request we are processing.
* @param response The HTTP Response we are processing.
* @throws java.lang.Excep tion
* @return
*/
public ActionForward execute(ActionM apping mapping, ActionForm form,
HttpServletRequ est request, HttpServletResp onse response)
throws Exception {
loginform lform=(com.myap p.struts.loginf orm) form;
// String uid="Welcome" + lform.getUserid ()+"";
// request.getSess ion().setAttrib ute("userName", uid);
response.setHea der("Cache-Control","no-cache"); //Forces caches to obtain a new copy of the page from the origin server
response.setHea der("Cache-Control","no-store"); //Directs caches not to store the page under any circumstance
response.setDat eHeader("Expire s", 0); //Causes the proxy cache to see the page as "stale"
response.setHea der("Pragma","n o-cache");
request.getSess ion();
request.getSess ion().setAttrib ute("loginform" ,lform);
return mapping.findFor ward("success") ;
}
}
[/code]
logoutaction.ja va is as follows
[code=java]
/*
* loginaction.jav a
*
* Created on February 26, 2007, 10:48 AM
*/
package com.myapp.strut s;
import javax.servlet.h ttp.HttpServlet Request;
import javax.servlet.h ttp.HttpServlet Response;
import org.apache.stru ts.action.Actio n;
import org.apache.stru ts.action.Actio nForm;
import org.apache.stru ts.action.Actio nMapping;
import org.apache.stru ts.action.Actio nForward;
/**
*
* @author root
* @version
*/
public class logoutaction extends Action {
/* forward name="success" path="" */
// private final static String SUCCESS = "success";
/**
* This is the action called from the Struts framework.
* @param mapping The ActionMapping used to select this instance.
* @param form The optional ActionForm bean for this request.
* @param request The HTTP Request we are processing.
* @param response The HTTP Response we are processing.
* @throws java.lang.Excep tion
* @return
*/
public ActionForward execute(ActionM apping mapping, ActionForm form,
HttpServletRequ est request, HttpServletResp onse response)
throws Exception
{
// request.getSess ion().setAttrib ute("userName", null);
request.getSess ion().removeAtt ribute("loginfo rm");
request.getSess ion().invalidat e();
return mapping.findFor ward("logout");
}
}
[/code]
So when i clicks on logout image the control is forwarded to index.jsp
But when i press backbutton of the browser the main.jsp page is displayed.
i.e. logout is not working properly.
I want functionality like when back button will be pressed "session expirred messaged should be displayed and control should be forwared to index.jsp page
Can anybody help me out with this
Comment