Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

unable to exceute logout program

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 597
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Geeta which book are you using for struts2?
 
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Geeta Ravikanti
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It's just a flesh wound! Or a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic