473,289 Members | 2,089 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

logout problem using struts

10
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
Expand|Select|Wrap|Line Numbers
  1.   <action input="index.jsp" name="loginform" path="/login" scope="session" type="com.myapp.struts.loginaction">
  2.             <forward name="success" path="/main.jsp"/>
  3.         </action>
  4.  
  5.         <action  path="/logout" scope="session" type="com.myapp.struts.logoutaction">
  6.             <forward name="logout" path="/index.jsp"/>
  7.     </action>
  8.  
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
Expand|Select|Wrap|Line Numbers
  1. <html:link page="/logout.do"> <img src="img/logout_deselect.jpg" name="Image11"  height="30" border="0"> </html:link> 
  2.  
Now actionforms are as follows
loginaction.java
Expand|Select|Wrap|Line Numbers
  1. /*
  2.  * loginaction.java
  3.  *
  4.  * Created on February 26, 2007, 10:48 AM
  5.  */
  6.  
  7. package com.myapp.struts;
  8.  
  9. import javax.servlet.http.HttpServletRequest;
  10. import javax.servlet.http.HttpServletResponse;
  11.  
  12. import org.apache.struts.action.Action;
  13. import org.apache.struts.action.ActionForm;
  14. import org.apache.struts.action.ActionMapping;
  15. import org.apache.struts.action.ActionForward;
  16. /**
  17.  *
  18.  * @author root
  19.  * @version
  20.  */
  21.  
  22. public class loginaction extends Action {
  23.         /**
  24.      * This is the action called from the Struts framework.
  25.      * @param mapping The ActionMapping used to select this instance.
  26.      * @param form The optional ActionForm bean for this request.
  27.      * @param request The HTTP Request we are processing.
  28.      * @param response The HTTP Response we are processing.
  29.      * @throws java.lang.Exception
  30.      * @return
  31.      */
  32.     public ActionForward execute(ActionMapping mapping, ActionForm  form,
  33.             HttpServletRequest request, HttpServletResponse response)
  34.             throws Exception {
  35.  
  36.         loginform lform=(com.myapp.struts.loginform) form;
  37.      //   String uid="Welcome" + lform.getUserid()+"";
  38.        // request.getSession().setAttribute("userName",uid);
  39.         response.setHeader("Cache-Control","no-cache"); //Forces caches to obtain a new copy of the page from the origin server
  40. response.setHeader("Cache-Control","no-store"); //Directs caches not to store the page under any circumstance
  41. response.setDateHeader("Expires", 0); //Causes the proxy cache to see the page as "stale"
  42. response.setHeader("Pragma","no-cache");
  43.  
  44.         request.getSession();
  45.         request.getSession().setAttribute("loginform",lform);
  46.         return mapping.findForward("success");
  47.     }
  48. }
  49.  
logoutaction.java is as follows
Expand|Select|Wrap|Line Numbers
  1.  /*
  2.  * loginaction.java
  3.  *
  4.  * Created on February 26, 2007, 10:48 AM
  5.  */
  6.  
  7. package com.myapp.struts;
  8.  
  9. import javax.servlet.http.HttpServletRequest;
  10. import javax.servlet.http.HttpServletResponse;
  11.  
  12. import org.apache.struts.action.Action;
  13. import org.apache.struts.action.ActionForm;
  14. import org.apache.struts.action.ActionMapping;
  15. import org.apache.struts.action.ActionForward;
  16. /**
  17.  *
  18.  * @author root
  19.  * @version
  20.  */
  21.  
  22. public class logoutaction extends Action {
  23.  
  24.     /* forward name="success" path="" */
  25.  //   private final static String SUCCESS = "success";
  26.  
  27.     /**
  28.      * This is the action called from the Struts framework.
  29.      * @param mapping The ActionMapping used to select this instance.
  30.      * @param form The optional ActionForm bean for this request.
  31.      * @param request The HTTP Request we are processing.
  32.      * @param response The HTTP Response we are processing.
  33.      * @throws java.lang.Exception
  34.      * @return
  35.      */
  36.     public ActionForward execute(ActionMapping mapping, ActionForm  form,
  37.             HttpServletRequest request, HttpServletResponse response)
  38.             throws Exception 
  39.     {
  40.       // request.getSession().setAttribute("userName",null);
  41.        request.getSession().removeAttribute("loginform");
  42.        request.getSession().invalidate();
  43.        return mapping.findForward("logout");
  44.  
  45.     }
  46. }
  47.  


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
Sep 3 '07 #1
1 14011
acoder
16,027 Expert Mod 8TB
Javascript and Java are not the same language. Moved to the Java forum.
Sep 3 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Cedric | last post by:
Hello, I'm developping my first Struts application. I've got this error: Cannot find message resources under key org.apache.struts.action.MESSAGE web.xml <servlet>...
0
by: swiss | last post by:
how can i code logout in a struts application.I have used session.invalidate but it is not accurately logging out from the session .please help me out to solve this problem.
1
by: Chaitanya | last post by:
please tell me ,the tld files like struts-bean.tld, struts-html.tld, struts-logic.tld are generated automatically or done by ourselves using Netbeans. As they are automatically generated in...
0
by: kisc71117 | last post by:
When accessing my JSP I get the following error: org.apache.jasper.JasperException: Missing message for key "button.add" my error message javax.servlet.ServletException: Missing message for key...
1
by: nithiya sri | last post by:
i am new to struts.I try running struts application in Eclipse with the tomcat plug in .. it shows the following error:; please help me in this... SEVERE: Error loading WebappClassLoader ...
3
by: shanmukhi | last post by:
hi all, i got a problem with struts. iam unable to find it. i have written an action class, form bean class and a jsp page on submitting form, request is going to action class but it is not...
8
by: ajos | last post by:
hi frnds, im trying to convert my servlets database configuration from ms access to mysql database.however im getting some error like no driver found exception. to verify this error ive...
8
by: ajos | last post by:
hi frnds, the situation is im developing a web application in struts-- my specifications-eclipse3.2.2,struts1.1,tomcat5.5.23 mysql5.0 db. the scenario-i have a jsp page which adds the...
3
by: arasub | last post by:
ep 20, 2007 11:25:57 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.