File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts 2 Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 Problem" Watch "Struts 2 Problem" New topic

Struts 2 Problem

anieruddha gaikwad

Joined: Nov 26, 2006
Posts: 13
Hi All,

What I want is Interceptor should execute before each action-execution, and if it returns result success, the action should be executed. But right now, on calling each action, the interceptor is executing and, based on its result return, the particulat jsp page in getting called. i.e.
Lets suppose I called action : Action1,
1. 'LoginInterceptor' Interceptor gets called
2. If 'LoginInterceptor' retruns "success', then '/WEB-INF/jsp/Action1Success.jsp' is being displayed on browser, Irrespective of the execute() method return result.
Ankit Garg

Joined: Aug 03, 2008
Posts: 9465

anieruddha please Use Code Tags when you post a source code. That way your code looks formatted. Unformatted code is hard to read. You can add code tags by wrapping your code in [code] [/code] tags. You can edit your message using button and then add code tags to it.

When the login is successful, you need to return invocation.invoke() instead of "success". See this tutorial...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
David Newton

Joined: Sep 29, 2008
Posts: 12617

Also, the login itself shouldn't be done in an interceptor: the only thing an interceptor should be responsible for is checking to see if (a) the user needs to be logged in, and (b) that the user is logged in. Login itself should be handled by an action.
I agree. Here's the link:
subject: Struts 2 Problem
It's not a secret anymore!