You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Srineel Mazumdar <sm...@gmail.com> on 2011/11/20 20:10:07 UTC

Interceptor cleaning valuestack

Hi,

I am creating a small struts2 application and the problem that I face is
that the inteceptor is clearing the value stack and I cannot get the values
in JSP in my action.
Please help.

Regards,
Srineel

Re: Interceptor cleaning valuestack

Posted by Srineel Mazumdar <sm...@gmail.com>.
Dave,

Thanks a lot for providing the solution. I put default stack in the
interceptor stack and the functionality is running properly. However if I
do not use stack and directly use the interceptor, it gives the following
error :

HTTP Status 404 -
/Struts2/login.action;jsessionid=B902A6322742861B6ED2F1FB35C61766

Please help.

struts.xml (modified)

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="true" />
<include file="struts-default.xml" />
<package name="practice" extends="struts-default">
<interceptors>
*<interceptor name="logger1" class="com.home.practice.LoggerInterceptor" />*
<interceptor name="before" class="com.home.practice.PreViewInterceptor" />
<interceptor name="after" class="com.home.practice.PostViewInterceptor" />
</interceptors>
<action name="loginCancel">
<result>/Login.jsp</result>
</action>
<action name="login" class="com.home.practice.LoginAction">
* **<interceptor-ref name="logger1" />*
<result name="input">/Login.jsp</result>
<result name="error">/Login.jsp</result>
<result name="cancel" type="redirect">/Login.jsp</result>
<result>/UserInfo.jsp</result>
</action>
<action name="userinfo" class="com.home.practice.UserInfoAction">
<result name="summary">/Welcome.jsp</result>
</action>

</package>
</struts>


On Mon, Nov 21, 2011 at 1:34 AM, Dave Newton <da...@gmail.com> wrote:

> By using a complete stack in the action's <interceptor-ref> config element,
> or by combining stacks as with any interceptor configuration.
>
> http://struts.apache.org/2.x/docs/interceptor-configuration.html
>
> Dave
>
> On Sun, Nov 20, 2011 at 2:59 PM, Srineel Mazumdar <smaz19584@gmail.com
> >wrote:
>
> > Hi Dave,
> > *
> > *
> > *"In any case, when you define an <interceptor-ref> for a specific
> action,*
> > *you must define *all* of the interceptors for that action"*
> > *
> > *
> > How can this be done ?
> >
> > Thanks,
> > Srineel
> >
> > On Mon, Nov 21, 2011 at 1:26 AM, Dave Newton <da...@gmail.com>
> > wrote:
> >
> > > On Sun, Nov 20, 2011 at 2:47 PM, Srineel Mazumdar <smaz19584@gmail.com
> > > >wrote:
> > >
> > > > I intend to use only logger1 interceptor.
> > > >
> > > > I want to enable only one interceptor ie logger1. How can I do so?
> > > >
> > >
> > > By doing what you did.
> > >
> > > However, as I stated, this means that essentially no other S2
> > functionality
> > > will be present, including setting form values on the action,
> validation,
> > > workflow, etc.
> > >
> > > Dave
> > >
> >
>

Re: Interceptor cleaning valuestack

Posted by Dave Newton <da...@gmail.com>.
By using a complete stack in the action's <interceptor-ref> config element,
or by combining stacks as with any interceptor configuration.

http://struts.apache.org/2.x/docs/interceptor-configuration.html

Dave

On Sun, Nov 20, 2011 at 2:59 PM, Srineel Mazumdar <sm...@gmail.com>wrote:

> Hi Dave,
> *
> *
> *"In any case, when you define an <interceptor-ref> for a specific action,*
> *you must define *all* of the interceptors for that action"*
> *
> *
> How can this be done ?
>
> Thanks,
> Srineel
>
> On Mon, Nov 21, 2011 at 1:26 AM, Dave Newton <da...@gmail.com>
> wrote:
>
> > On Sun, Nov 20, 2011 at 2:47 PM, Srineel Mazumdar <smaz19584@gmail.com
> > >wrote:
> >
> > > I intend to use only logger1 interceptor.
> > >
> > > I want to enable only one interceptor ie logger1. How can I do so?
> > >
> >
> > By doing what you did.
> >
> > However, as I stated, this means that essentially no other S2
> functionality
> > will be present, including setting form values on the action, validation,
> > workflow, etc.
> >
> > Dave
> >
>

Re: Interceptor cleaning valuestack

Posted by Srineel Mazumdar <sm...@gmail.com>.
Hi Dave,
*
*
*"In any case, when you define an <interceptor-ref> for a specific action,*
*you must define *all* of the interceptors for that action"*
*
*
How can this be done ?

Thanks,
Srineel

On Mon, Nov 21, 2011 at 1:26 AM, Dave Newton <da...@gmail.com> wrote:

> On Sun, Nov 20, 2011 at 2:47 PM, Srineel Mazumdar <smaz19584@gmail.com
> >wrote:
>
> > I intend to use only logger1 interceptor.
> >
> > I want to enable only one interceptor ie logger1. How can I do so?
> >
>
> By doing what you did.
>
> However, as I stated, this means that essentially no other S2 functionality
> will be present, including setting form values on the action, validation,
> workflow, etc.
>
> Dave
>

Re: Interceptor cleaning valuestack

Posted by Dave Newton <da...@gmail.com>.
On Sun, Nov 20, 2011 at 2:47 PM, Srineel Mazumdar <sm...@gmail.com>wrote:

> I intend to use only logger1 interceptor.
>
> I want to enable only one interceptor ie logger1. How can I do so?
>

By doing what you did.

However, as I stated, this means that essentially no other S2 functionality
will be present, including setting form values on the action, validation,
workflow, etc.

Dave

Re: Interceptor cleaning valuestack

Posted by Srineel Mazumdar <sm...@gmail.com>.
Apologies for posting my query in this fashion. I am a newcomer to this
group. The idea is to make a very simple Struts2 Login page. If the user
gives correct user id and password, the flow will get directed to the user
ino page where all the info will be put by user. After clicking submit, the
flow goes to the success page.

I intend to use only logger1 interceptor.

"*In any case, when you define an <interceptor-ref> for a specific action,*
*you must define *all* of the interceptors for that action. Your stack on
the "login" action contains *only* the "logger1" interceptor, bypassing all
of the built-in Struts 2 functionality, including the "params" interceptor.

This means the request parameters will not be set on your action.*
"
I am not clear on what you mean. I want to enable only one interceptor ie
logger1. How can I do so?

Thanks in Advance.
On Mon, Nov 21, 2011 at 1:08 AM, Dave Newton <da...@gmail.com> wrote:

> How about you describe the code the code and behavior and post it, rather
> than making us download a zip, extract it, look at it and/or run it, etc?
>
> Btw, the comment in your PostViewInterceptor is a bit misleading; the S.o.p
> will execute before the view is rendered, because it occurs before the
> invocation.invoke().
>
> In any case, when you define an <interceptor-ref> for a specific action,
> you must define *all* of the interceptors for that action. Your stack on
> the "login" action contains *only* the "logger1" interceptor, bypassing all
> of the built-in Struts 2 functionality, including the "params" interceptor.
>
> This means the request parameters will not be set on your action.
>
> Dave
>
> On Sun, Nov 20, 2011 at 2:29 PM, Srineel Mazumdar <smaz19584@gmail.com
> >wrote:
>
> > Please enable and disable the interceptor logger1. When interceptor is
> > disable, I get userid/password in action, but not ,when enabled. If
> > possible please run the code and check
> >
> > On Mon, Nov 21, 2011 at 12:56 AM, Dave Newton <da...@gmail.com>
> > wrote:
> >
> > > "The" interceptor? Which interceptor? What makes you think an
> interceptor
> > > is clearing the value stack?
> > >
> > > Dave
> > >
> > > On Sun, Nov 20, 2011 at 2:10 PM, Srineel Mazumdar <smaz19584@gmail.com
> > > >wrote:
> > >
> > > > Hi,
> > > >
> > > > I am creating a small struts2 application and the problem that I face
> > is
> > > > that the inteceptor is clearing the value stack and I cannot get the
> > > values
> > > > in JSP in my action.
> > > > Please help.
> > > >
> > > > Regards,
> > > > Srineel
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > For additional commands, e-mail: user-help@struts.apache.org
> > > >
> > >
> >
>

Re: Interceptor cleaning valuestack

Posted by Dave Newton <da...@gmail.com>.
How about you describe the code the code and behavior and post it, rather
than making us download a zip, extract it, look at it and/or run it, etc?

Btw, the comment in your PostViewInterceptor is a bit misleading; the S.o.p
will execute before the view is rendered, because it occurs before the
invocation.invoke().

In any case, when you define an <interceptor-ref> for a specific action,
you must define *all* of the interceptors for that action. Your stack on
the "login" action contains *only* the "logger1" interceptor, bypassing all
of the built-in Struts 2 functionality, including the "params" interceptor.

This means the request parameters will not be set on your action.

Dave

On Sun, Nov 20, 2011 at 2:29 PM, Srineel Mazumdar <sm...@gmail.com>wrote:

> Please enable and disable the interceptor logger1. When interceptor is
> disable, I get userid/password in action, but not ,when enabled. If
> possible please run the code and check
>
> On Mon, Nov 21, 2011 at 12:56 AM, Dave Newton <da...@gmail.com>
> wrote:
>
> > "The" interceptor? Which interceptor? What makes you think an interceptor
> > is clearing the value stack?
> >
> > Dave
> >
> > On Sun, Nov 20, 2011 at 2:10 PM, Srineel Mazumdar <smaz19584@gmail.com
> > >wrote:
> >
> > > Hi,
> > >
> > > I am creating a small struts2 application and the problem that I face
> is
> > > that the inteceptor is clearing the value stack and I cannot get the
> > values
> > > in JSP in my action.
> > > Please help.
> > >
> > > Regards,
> > > Srineel
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> >
>

Re: Interceptor cleaning valuestack

Posted by Srineel Mazumdar <sm...@gmail.com>.
Please enable and disable the interceptor logger1. When interceptor is
disable, I get userid/password in action, but not ,when enabled. If
possible please run the code and check

On Mon, Nov 21, 2011 at 12:56 AM, Dave Newton <da...@gmail.com> wrote:

> "The" interceptor? Which interceptor? What makes you think an interceptor
> is clearing the value stack?
>
> Dave
>
> On Sun, Nov 20, 2011 at 2:10 PM, Srineel Mazumdar <smaz19584@gmail.com
> >wrote:
>
> > Hi,
> >
> > I am creating a small struts2 application and the problem that I face is
> > that the inteceptor is clearing the value stack and I cannot get the
> values
> > in JSP in my action.
> > Please help.
> >
> > Regards,
> > Srineel
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
>

Re: Interceptor cleaning valuestack

Posted by Dave Newton <da...@gmail.com>.
"The" interceptor? Which interceptor? What makes you think an interceptor
is clearing the value stack?

Dave

On Sun, Nov 20, 2011 at 2:10 PM, Srineel Mazumdar <sm...@gmail.com>wrote:

> Hi,
>
> I am creating a small struts2 application and the problem that I face is
> that the inteceptor is clearing the value stack and I cannot get the values
> in JSP in my action.
> Please help.
>
> Regards,
> Srineel
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>