struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kedar Choudhary" <>
Subject RE: about current action name acsess
Date Fri, 29 Feb 2008 07:29:34 GMT
When you are directing the user to login page, you need to 'remember' the
action (rather URL) he was invoking. This needs to be made available to
Login action so that on successful login user can be redirected to the page
he was originally trying to access.

One of the ways to remember the original URL is to store it in session. But
there are certain issues with this approach. I prefer passing around the
original URL to login form and then to Login action.

public class AuthenticationInterceptor implements Interceptor {
  public String intercept(final ActionInvocation actionInvocation)
      throws Exception {
    if (!isAuthenticated) {
      final ActionContext ctx = actionInvocation.getInvocationContext();
      final HttpServletRequest request = (HttpServletRequest) ctx
      if (request != null) {
        StringBuffer requestURL = request.getRequestURL();
        if (request.getQueryString() != null) {
        ctx.put("postLoginURL", requestURL.toString());
      return Action.LOGIN;

      <result name="login">login.jsp</result>

  <s:form label="Login" action="login">
    <s:textfield key="loginId" />
    <s:password key="password" />
    <s:hidden name="postLoginURL" value="%{#postLoginURL}"></s:hidden>
    <s:submit />
  public String execute() throws Exception {
      if(user != null) {
        if(postLoginURL != null && !postLoginURL.isEmpty())
          return "redirect";
        return SUCCESS;

    <action name="login_*" method="{1}" class="LoginAction">
      <result type="redirect-action">home</result>
      <result name="redirect" type="redirect">

-----Original Message-----
From: hns [] 
Sent: Friday, February 29, 2008 11:29 AM
Subject: Re: about current action name acsess

i have one interceptor(reference of mailreader example of 2.0.11 ) for check
in session about username
if person click on some authorized link like portfolio they should directly
to login action 
i have achieved this thing using interceptor

now my problem is that
when person submit his username and password ,he directly goes to the
mainmenu action 
because i have set in struts.xml
<action name="Login_*"  method="{1}" class="authentic.Login">
            <result name="input">/Login.jsp</result>
            <result name="cancel" type="redirect-action">Welcome</result>
            <result type="redirect-action">MainMenu</result>
            <interceptor-ref name="guest"/>

<action name="portfol_main"  >
	<interceptor-ref name="user"/>
but i want to grab them directly to portfol_main action 
how  can i achieve it?

View this message in context:
Sent from the Struts - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message