I am using Struts2.0, Tomcat5.5 on windows XP system.
I am trying to keep track of time taken by a action class. For this I am trying to use interceptor. I specify this in the strus.xml as The interceptor is defined in the struts.xml as Now the Interceptor code is as As can be seen in the code I am trying two ways to get this timeTaken value to the result="success" JSP page
1. Via bean property i.e. private String ruleRunTimeTaken; 2. Via putting it in session attribute MyTime
Now in the result JSP I am trying to access this time taken as Here the bean property way is not working at all. I am getting blank always. May be this is not the correct way to do it. Please suggest how to get the timeTaken value across to the JSP page from Interceptor class.
Now the session thing sometimes work sometimes not. i.e. sometime I get the timeTaken value and other time it is blank. I am really confused
Please help me understand this. Thanks in advance for taking time out to help me.
I'm not sure if your logic is correct. The execution time can be calculated only after the action has been invoked. In that case, what you put in a session can only be displayed by the next invocation. This is the reason why the first invocation always displays the blank and subsequently, it'll display the previous execution time.
SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
Joined: Mar 26, 2009
Thanks Freddy for pitching in. So how do you think shall I get this done. I want it to be configurable- as later on, I see myself tracking this timeTaken thing for other action classes.
What is the difference between Filter and Interceptor; shall I use Filter in this scenario.
One more thing- does the bean property set in the interceptor, set on ValueStack and subsequently can be accessed on the JSP pages using ELs.
But someone here truly said that by the time the interceptor is getting the end time and the difference i.e. timeTaken the response has alraedy been committed. So how to get this value to the JSP page. Another question - if we have an instance variable in the Interceptor class and we have getter and setter for that in the interceptor class - will they be put on the valueStack similar to what happen in case of Action classes.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com