*
The moose likes Struts and the fly likes unable to exceute logout program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "unable to exceute logout program" Watch "unable to exceute logout program" New topic
Author

unable to exceute logout program

Geeta Ravikanti
Ranch Hand

Joined: Mar 26, 2008
Posts: 46
Hi All,
I am doing the program for login/logout in strtus2
But when ever I am executing the program from tomcat server
its throwing the exception like following

java.lang.IllegalArgumentException: The execute() is not defined in action class org.students.LogOut
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:363)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:228)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:202)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:177)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:200)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:115)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:200)
etc..................


here LogOut.java


package org.students;

import javax.servlet.http.*;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ActionContext;
import java.util.*;

public class LogOut extends ActionSupport {
public String execute() throws Exception {
Map session = ActionContext.getContext().getSession();
session.remove("logged-in");
return SUCCESS;
}
}

when ever above program is run sceesfully it will go to chechkLogin.jsp

here chechkLogin.jsp

<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ page language="java" contentType="text/html" import="java.util.*"%>
<html>
<head>
<title>Check validate!</title>
</head>
<body>
//<s:if test="#session.login != 'admin'">
<jsp:forward page="/remora.jsp" />
</s:if>
</body>
</html>


I am unable to getting what are the modifications I have to made in above programs

Please any one help in this

Thanks&Regrads
Geeta
Sandeep Awasthi
Ranch Hand

Joined: Oct 23, 2003
Posts: 597
Geeta which book are you using for struts2?


Sandeep
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
Could you use the code tag to post, and also share your struts.xml? How is your LogOut action invoked? From your JSP, it doesn't call that action.


SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
Geeta Ravikanti
Ranch Hand

Joined: Mar 26, 2008
Posts: 46
Thank you for the reply

I am calling the Action class(LogOut.java) in jsp page like following

<%@ taglib prefix="s" uri="/struts-tags" %>

Welcome
<s roperty value="username"/>,
<br>
<br><br><br>
<a href="<s:url value = "/myjsp/remora.jsp"/>">Home</a>
<a href="<%= request.getContextPath() %>/LogOut.action">Logout</a>

LogOut.java

package org.students;

import javax.servlet.http.*;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ActionContext;
import java.util.*;

public class LogOut extends ActionSupport {
public String execute() throws Exception {
Map session = ActionContext.getContext().getSession();
session.remove("logged-in");
return SUCCESS;
}
}

if its reun successfully it goes to checkLogin.jsp according to struts.xml

<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ page language="java" contentType="text/html" import="java.util.*"%>
<html>
<head>
<title>Check validate!</title>
</head>
<body>
//<s:if test="#session.login != 'admin'">
<jsp:forward page="/remora.jsp" />
</s:if>
</body>
</html>



here strtus.xml

<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="org.students" extends="struts-default">
<action name="RegisterUser" class="org.students.RegisterUser">
<result name="success">/myjsp/Success.jsp</result>
<result name="error">/myjsp/RegisterUser.jsp</result>
<result name="input">/myjsp/RegisterUser.jsp</result>
</action>
<action name="LogonUser" class="org.students.LogonUser">
<result name="success">/myjsp/LogonSuccess.jsp</result>
<result name="error">/myjsp/LogonUser.jsp</result>
</action>

<action name="LogOut" class="org.students.LogOut" >
<result name="success" type="redirect">/myjsp/checkLogin.jsp</result>
</action>
<action name="User" class="org.students.User">
<result name="success">/myjsp/Success.jsp</result>
<result name="error">/myjsp/User.jsp</result>
<result name="input">/myjsp/User.jsp</result>
</action>
<action name="*" >
<result>/myjsp/(1).jsp</result>
</action>
</package>
</struts>



here its my project structure

where can I made the changes
please any one help in this


Thanks&Regards
Geeta
 
GeeCON Prague 2014
 
subject: unable to exceute logout program