Chris,

Your algorithm with Calendars is realyl complicated, can't you simply
use System.currentTimeMillis() ?
Then, can you also add a log to the interceptor so that you can log
the value before you put it in the value stack ?
It will not solve your pb but it will make things more clear and will
help to debug.

You can look at this class too,
com.opensymphony.xwork2.interceptor.TimerInterceptor, they do the
same, only they don't put it in the value stack.

Cimballi


On Fri, Feb 19, 2010 at 11:39 AM, CRANFORD, CHRIS
<chris.cranf...@setech.com> wrote:
>
> My RequestTimerInterceptor is very basic and looks just like this below.  
> What I find is that if I use a <s:debug/> tag in my JSP, the action context 
> parameter is being set to 0 but the update at the end of the interceptor 
> isn't applied.
>
> What have I missed?
>
> public String interceptor(ActionInvocation actionInvocation)
> throws Exception {
>  // Get objects
>  ActionContext ac = actionInvocation.getInvocationContext();
>  Map parameters = ac.getParameters();
>  // Initialize variables
>  parameters.put(Constants.REQUEST_TIME_KEY,new Long(0));
>  ac.getValueStack().setValue(Constants.REQUEST_TIME_KEY,new Long(0));
>  // Get start time
>  Calendar started = Calendar.getInstance();
>  started.setTime(new Date());
>  // Invoke
>  String result = actionInvocation.invoke();
>  // Get end time and difference
>  Calendar ended = Calendar.getInstance();
>  Ended.setTime(new Date());
>  long diffMS = (ended.getTimeInMillis()-started.getTimeInMillis());
>  // Set values with total time
>  parameters.put(Constants.REQUEST_TIME_KEY,new Long(diffMS));
>  ac.getValueStack().setValue(Constants.REQUEST_TIME_KEY,new Long(diffMS));
>  return(result);
> }
>
> Chris
>
> -----Original Message-----
> From: Cimballi [mailto:cimballi.cimba...@gmail.com]
> Sent: Friday, February 19, 2010 10:16 AM
> To: Struts Users Mailing List
> Subject: Re: Interceptor
>
> Look at ParameterRemoverInterceptor for example, you can access the
> action context like this :
> ActionContext ac = invocation.getInvocationContext();
>
> And then you can set values in the value stack. Didn't test it but should 
> work.
>
> Cimballi
>
>
> On Fri, Feb 19, 2010 at 11:10 AM, CRANFORD, CHRIS
> <chris.cranf...@setech.com> wrote:
>> Is it possible to set a value in the request or valuestack from an
>> interceptor that contains the total time it took for the action to be
>> invoked and executed?  I have a requirement to show this on the JSP page
>> and didn't know if I could do this within the Interceptor or if I have
>> to do this in my base action object.
>>
>> Chris
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to