Hi, you've reached the website of Mark Menard, Freemason, developer, businessman, photographer, motorcyclist and all around nice guy.
The main joy in my life is Sylva, my loving partner and friend. (You will see plenty of pictures of her. Also check out our site.) My professonal career is running a consulting firm concentrating on business automation and custom software. I enjoy software development, motorcycles, photography, dancing, freemasonry and travel.
Here you will find galleries of my latest photos, thoughts on software development, freemasonry, the occassional politics, and other things. Enjoy your time here.
Mark
An ongoing photographic study of Freemasonry.
To contact Mark send an email to mark@mjm.net. You will receive an auto response from my mail server to verify you're not a spammer.
© Mark Menard 2002-2007
Unable to get request parameters in Action Class
Hi,
I am doing task on struts2. In that I have to use custom AutherizationInterceptor. In my custom Interceptor Im checking weather user is in session or not. And if he tries to attempt login I gave parameter in struts.xml as true So Im checking against it and interceptor redirects action to Home. But my problem is unable to get the request parameters in Home Action class.
Please help me I need to implement this code in my project.
My code is-------
In struts.xml for Login Attemp
<action name="home" class="com.mss.HomeAction">
<interceptor-ref name="authorizationInterceptor">
<param name="loginAttempt">true</param>
</interceptor-ref>
<result name="input">login.jsp</result>
<result name="login">login.jsp</result>
<result name="success">home.jsp</result>
</action>
My Interceptor -------
public class AutherizationInterceptor implements Interceptor,StrutsStatics {
//private HttpServletRequest httpServletRequest;
private boolean loginAttempt;
/** Creates a new instance of AuthorizationInterceptor */
public AuthorizationInterceptor() {
}
public void destroy() {
}
public void init() {
}
public String intercept(ActionInvocation actionInvocation) throws Exception {
final ActionContext context = actionInvocation.getInvocationContext();
Map session = context.getSession();
Action action = null;
if(loginAttempt) {
return actionInvocation.invoke();
} else {
if(session.get("userName") != null){
action = ( Action ) actionInvocation.getAction();
return actionInvocation.invoke();
} else {
return Action.LOGIN;
}
}
}
public void setLoginAttempt(boolean loginAttempt) {
this.loginAttempt = loginAttempt;
}
My Action Class*****
public String execute() {
resultType = SUCCESS;
String userName = getUserName();
System.err.println("hai ********");
String password = getPassword();
if(userName!=null && password != null) {
request.getSession().setAttribute("userName",userName);
request.getSession().setAttribute("password",password);
resultType = SUCCESS;
} else {
resultType = INPUT;
}
return resultType;
}
thanks in advance
Praveen