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
Expand|Select|Wrap|Line Numbers
- <action input="index.jsp" name="loginform" path="/login" scope="session" type="com.myapp.struts.loginaction">
- <forward name="success" path="/main.jsp"/>
- </action>
- <action path="/logout" scope="session" type="com.myapp.struts.logoutaction">
- <forward name="logout" path="/index.jsp"/>
- </action>
Expand|Select|Wrap|Line Numbers
- <html:link page="/logout.do"> <img src="img/logout_deselect.jpg" name="Image11" height="30" border="0"> </html:link>
loginaction.java
Expand|Select|Wrap|Line Numbers
- /*
- * loginaction.java
- *
- * Created on February 26, 2007, 10:48 AM
- */
- package com.myapp.struts;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.apache.struts.action.Action;
- import org.apache.struts.action.ActionForm;
- import org.apache.struts.action.ActionMapping;
- import org.apache.struts.action.ActionForward;
- /**
- *
- * @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.Exception
- * @return
- */
- public ActionForward execute(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response)
- throws Exception {
- loginform lform=(com.myapp.struts.loginform) form;
- // String uid="Welcome" + lform.getUserid()+"";
- // request.getSession().setAttribute("userName",uid);
- response.setHeader("Cache-Control","no-cache"); //Forces caches to obtain a new copy of the page from the origin server
- response.setHeader("Cache-Control","no-store"); //Directs caches not to store the page under any circumstance
- response.setDateHeader("Expires", 0); //Causes the proxy cache to see the page as "stale"
- response.setHeader("Pragma","no-cache");
- request.getSession();
- request.getSession().setAttribute("loginform",lform);
- return mapping.findForward("success");
- }
- }
Expand|Select|Wrap|Line Numbers
- /*
- * loginaction.java
- *
- * Created on February 26, 2007, 10:48 AM
- */
- package com.myapp.struts;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.apache.struts.action.Action;
- import org.apache.struts.action.ActionForm;
- import org.apache.struts.action.ActionMapping;
- import org.apache.struts.action.ActionForward;
- /**
- *
- * @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.Exception
- * @return
- */
- public ActionForward execute(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response)
- throws Exception
- {
- // request.getSession().setAttribute("userName",null);
- request.getSession().removeAttribute("loginform");
- request.getSession().invalidate();
- return mapping.findForward("logout");
- }
- }
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