You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by maven apache <ap...@gmail.com> on 2010/12/04 12:06:50 UTC

the result of the interceptor

Hi:
I am reading the book Struts2InAction,it is rather powerful.

And I thought someting funny when reading the interceptor chapter:

Example:

public String intercept(ActionInvocation invocation) throws Exception {
    long startTime = System.currentTimeMillis(); //1
    String result = invocation.invoke(); //2
    long executionTime = System.currentTimeMillis() - startTime;
       ... log the time
...
    return
result;
}

The following is quoted from the book:

>Either way, when invoke()
>returns, a result has already been rendered. In other words, the response
page has
>already been sent back to the client

Since the response page has been sent to client .So I wonder if I return
null after calling the invocation.invoke()?

BTW,I do not have the development environment for a test nowtime,so I ask
here,hoping not distuirbing you guys. :)

Re: the result of the interceptor

Posted by Chris Pratt <th...@gmail.com>.
It doesn't make much of a difference what you return after you call
invocation.invoke(), but since you can opt not to call it and just return
"login-required" or "password-reset", you can use it to control the flow of
the application, just make sure you do it before you call invoke =8^)
  (*Chris*)

On Sat, Dec 4, 2010 at 3:06 AM, maven apache <ap...@gmail.com> wrote:

> Hi:
> I am reading the book Struts2InAction,it is rather powerful.
>
> And I thought someting funny when reading the interceptor chapter:
>
> Example:
>
> public String intercept(ActionInvocation invocation) throws Exception {
>    long startTime = System.currentTimeMillis(); //1
>    String result = invocation.invoke(); //2
>    long executionTime = System.currentTimeMillis() - startTime;
>       ... log the time
> ...
>    return
> result;
> }
>
> The following is quoted from the book:
>
> >Either way, when invoke()
> >returns, a result has already been rendered. In other words, the response
> page has
> >already been sent back to the client
>
> Since the response page has been sent to client .So I wonder if I return
> null after calling the invocation.invoke()?
>
> BTW,I do not have the development environment for a test nowtime,so I ask
> here,hoping not distuirbing you guys. :)
>