You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by david chan <da...@yahoo.com> on 2003/07/14 05:26:05 UTC

tracking user activities: how to ignore action chaining (or server side forward)

Hi,
 I am writing a RequestProcessor that is a subclass of
Struts 1.1 RequestProcessor, the purpose is to track
user activities, i.e. which link the user clicked,
which page the user requested etc.
 I override the method processForwardConfig, and put
my tracking function first, here is how it looks:

//my code to log user request
logPage(request.getRequestURI());
super.processForwardConfig(request, response, forward
);


 However, there is one problem with this approach, 
If there is action chaining (or server side forward),
that will be also logged, but that is not the user
requested URI, and I don't need to log any of chained
action URI or server side forwarded URI. 

 Any suggestion how to deal with this problem?

Thanks.
David

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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


Re: tracking user activities: how to ignore action chaining (or server side forward)

Posted by Kris Schneider <kr...@dotech.com>.
Sorry, filters were introduced in Servlet 2.3. What you might try doing is using
a request attribute as a flag to indicate that you've already logged the
requested URI. Maybe something like:

if (request.getAttribute(MyConstants.URI_LOG_FLAG) == null) {
  request.setAttribute(MyConstants.URI_LOG_FLAG, Boolean.TRUE);
  logPage(request.getRequestURI());
}
super.processForwardConfig(request, response, forward);

If you get the chance to move to a Servlet 2.3 container, filters will work just
fine in combination with Struts.

Quoting david chan <da...@yahoo.com>:

> My company using Websphere 4.0.5, and it only supports
> servlet 2.2. Does filter only operate on the original
> client request for servlet 2.2 also? Can filter works
> well with Struts actionservlet?
> 
> Thanks.
> David
> 
> 
> 
> --- Kris Schneider <kr...@dotech.com> wrote:
> > Seems like the easiest thing to do would be to write
> > a Filter mapped to "/*"
> > that uses HttpServletRequest.getRequestURI to
> > capture the requested URI. In a
> > conformant Servler 2.3 container, the Filter will
> > only operate on the original
> > client request, not forwards or includes.
> > 
> > Quoting david chan <da...@yahoo.com>:
> > 
> > > Hi,
> > >  I am writing a RequestProcessor that is a
> > subclass of
> > > Struts 1.1 RequestProcessor, the purpose is to
> > track
> > > user activities, i.e. which link the user clicked,
> > > which page the user requested etc.
> > >  I override the method processForwardConfig, and
> > put
> > > my tracking function first, here is how it looks:
> > > 
> > > //my code to log user request
> > > logPage(request.getRequestURI());
> > > super.processForwardConfig(request, response,
> > forward
> > > );
> > > 
> > > 
> > >  However, there is one problem with this approach,
> > 
> > > If there is action chaining (or server side
> > forward),
> > > that will be also logged, but that is not the user
> > > requested URI, and I don't need to log any of
> > chained
> > > action URI or server side forwarded URI. 
> > > 
> > >  Any suggestion how to deal with this problem?
> > > 
> > > Thanks.
> > > David
> > 
> > -- 
> > Kris Schneider <ma...@dotech.com>
> > D.O.Tech       <http://www.dotech.com/>

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

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


Re: tracking user activities: how to ignore action chaining (or server side forward)

Posted by david chan <da...@yahoo.com>.
My company using Websphere 4.0.5, and it only supports
servlet 2.2. Does filter only operate on the original
client request for servlet 2.2 also? Can filter works
well with Struts actionservlet?

Thanks.
David



--- Kris Schneider <kr...@dotech.com> wrote:
> Seems like the easiest thing to do would be to write
> a Filter mapped to "/*"
> that uses HttpServletRequest.getRequestURI to
> capture the requested URI. In a
> conformant Servler 2.3 container, the Filter will
> only operate on the original
> client request, not forwards or includes.
> 
> Quoting david chan <da...@yahoo.com>:
> 
> > Hi,
> >  I am writing a RequestProcessor that is a
> subclass of
> > Struts 1.1 RequestProcessor, the purpose is to
> track
> > user activities, i.e. which link the user clicked,
> > which page the user requested etc.
> >  I override the method processForwardConfig, and
> put
> > my tracking function first, here is how it looks:
> > 
> > //my code to log user request
> > logPage(request.getRequestURI());
> > super.processForwardConfig(request, response,
> forward
> > );
> > 
> > 
> >  However, there is one problem with this approach,
> 
> > If there is action chaining (or server side
> forward),
> > that will be also logged, but that is not the user
> > requested URI, and I don't need to log any of
> chained
> > action URI or server side forwarded URI. 
> > 
> >  Any suggestion how to deal with this problem?
> > 
> > Thanks.
> > David
> 
> -- 
> Kris Schneider <ma...@dotech.com>
> D.O.Tech       <http://www.dotech.com/>
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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


Re: tracking user activities: how to ignore action chaining (or server side forward)

Posted by Kris Schneider <kr...@dotech.com>.
Absolutely. One place to start would be Sun's own J2EE 1.3 Tutorial:

http://java.sun.com/j2ee/tutorial/1_3-fcs/index.html

Specifically, there's a section called "Java Servlet Technology":

http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets.html

Also, the Servlet 2.3 Specification is the definitive guide and it's not 
that bad a read:

http://www.jcp.org/aboutJava/communityprocess/final/jsr053/

And there's always the Servlet home page itself:

http://java.sun.com/products/servlet/

Prashanth.S wrote:
> Hi kris,
> Thanks for the info.Iam a newbie to java and i came to know after reading books that their functionality is allmost similar.Now through u i came to know that they r different.Thanku very much for guiding me.Is there any resource present on net that would guide me in this matter???
> Thanks
> Prashanth
> 
> Kris Schneider <kr...@dotech.com> wrote:
> Prashanth,
> 
> Thanks, but my point was that they're really nothing alike. I wasn't 
> asking the questions because I didn't know the answers, I was asking 
> because the answers would illustrate some of the differences. If the 
> information in the link you provided implies that event listeners and 
> filters are almost the same thing then it's horribly misleading.
> 
> Prashanth.S wrote:
> 
>>Hi Kris,
>>I have studied eventlisteners in a book[programming jakarta struts].I think below mentioned url will provide u with the required info.. 
>>
>>http://www.onjava.com/pub/a/onjava/2001/04/12/listeners.html?page=3
>>
>>Thanks
>>Prashanth
>>
>>Kris Schneider wrote:
>>I don't really see how event listeners and filters are almost the same thing.
>>Can you elaborate? Is it possible to provide a customized request or response
>>object through an event listener? Can event listeners be mapped to either a
>>specific servlet or URL pattern?
>>
>>Quoting "Prashanth.S" :
>>
>>
>>
>>>I think u can also use eventlisteners which are allmost same thing as
>>>filters..
>>>Regards
>>>Prashanth
>>>
>>>Kris Schneider wrote:
>>>Seems like the easiest thing to do would be to write a Filter mapped to
>>>"/*"
>>>that uses HttpServletRequest.getRequestURI to capture the requested URI. In
>>>a
>>>conformant Servler 2.3 container, the Filter will only operate on the
>>>original
>>>client request, not forwards or includes.
>>>
>>>Quoting david chan :
>>>
>>>
>>>
>>>>Hi,
>>>>I am writing a RequestProcessor that is a subclass of
>>>>Struts 1.1 RequestProcessor, the purpose is to track
>>>>user activities, i.e. which link the user clicked,
>>>>which page the user requested etc.
>>>>I override the method processForwardConfig, and put
>>>>my tracking function first, here is how it looks:
>>>>
>>>>//my code to log user request
>>>>logPage(request.getRequestURI());
>>>>super.processForwardConfig(request, response, forward
>>>>);
>>>>
>>>>
>>>>However, there is one problem with this approach, 
>>>>If there is action chaining (or server side forward),
>>>>that will be also logged, but that is not the user
>>>>requested URI, and I don't need to log any of chained
>>>>action URI or server side forwarded URI. 
>>>>
>>>>Any suggestion how to deal with this problem?
>>>>
>>>>Thanks.
>>>>David
>>>
>>>-- 
>>>Kris Schneider 
>>>D.O.Tech 
> 
> 

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>



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


Re: tracking user activities: how to ignore action chaining (or server side forward)

Posted by "Prashanth.S" <su...@yahoo.com>.
Hi kris,
Thanks for the info.Iam a newbie to java and i came to know after reading books that their functionality is allmost similar.Now through u i came to know that they r different.Thanku very much for guiding me.Is there any resource present on net that would guide me in this matter???
Thanks
Prashanth

Kris Schneider <kr...@dotech.com> wrote:
Prashanth,

Thanks, but my point was that they're really nothing alike. I wasn't 
asking the questions because I didn't know the answers, I was asking 
because the answers would illustrate some of the differences. If the 
information in the link you provided implies that event listeners and 
filters are almost the same thing then it's horribly misleading.

Prashanth.S wrote:
> Hi Kris,
> I have studied eventlisteners in a book[programming jakarta struts].I think below mentioned url will provide u with the required info.. 
> 
> http://www.onjava.com/pub/a/onjava/2001/04/12/listeners.html?page=3
> 
> Thanks
> Prashanth
> 
> Kris Schneider wrote:
> I don't really see how event listeners and filters are almost the same thing.
> Can you elaborate? Is it possible to provide a customized request or response
> object through an event listener? Can event listeners be mapped to either a
> specific servlet or URL pattern?
> 
> Quoting "Prashanth.S" :
> 
> 
>>I think u can also use eventlisteners which are allmost same thing as
>>filters..
>>Regards
>>Prashanth
>>
>>Kris Schneider wrote:
>>Seems like the easiest thing to do would be to write a Filter mapped to
>>"/*"
>>that uses HttpServletRequest.getRequestURI to capture the requested URI. In
>>a
>>conformant Servler 2.3 container, the Filter will only operate on the
>>original
>>client request, not forwards or includes.
>>
>>Quoting david chan :
>>
>>
>>>Hi,
>>>I am writing a RequestProcessor that is a subclass of
>>>Struts 1.1 RequestProcessor, the purpose is to track
>>>user activities, i.e. which link the user clicked,
>>>which page the user requested etc.
>>>I override the method processForwardConfig, and put
>>>my tracking function first, here is how it looks:
>>>
>>>//my code to log user request
>>>logPage(request.getRequestURI());
>>>super.processForwardConfig(request, response, forward
>>>);
>>>
>>>
>>>However, there is one problem with this approach, 
>>>If there is action chaining (or server side forward),
>>>that will be also logged, but that is not the user
>>>requested URI, and I don't need to log any of chained
>>>action URI or server side forwarded URI. 
>>>
>>>Any suggestion how to deal with this problem?
>>>
>>>Thanks.
>>>David
>>
>>-- 
>>Kris Schneider 
>>D.O.Tech 

-- 
Kris Schneider 
D.O.Tech 



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



---------------------------------
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

Re: tracking user activities: how to ignore action chaining (or server side forward)

Posted by Kris Schneider <kr...@dotech.com>.
Prashanth,

Thanks, but my point was that they're really nothing alike. I wasn't 
asking the questions because I didn't know the answers, I was asking 
because the answers would illustrate some of the differences. If the 
information in the link you provided implies that event listeners and 
filters are almost the same thing then it's horribly misleading.

Prashanth.S wrote:
> Hi Kris,
> I have studied eventlisteners in a book[programming jakarta struts].I think below mentioned url will provide u with the required info.. 
>  
> http://www.onjava.com/pub/a/onjava/2001/04/12/listeners.html?page=3
>  
> Thanks
> Prashanth
> 
> Kris Schneider <kr...@dotech.com> wrote:
> I don't really see how event listeners and filters are almost the same thing.
> Can you elaborate? Is it possible to provide a customized request or response
> object through an event listener? Can event listeners be mapped to either a
> specific servlet or URL pattern?
> 
> Quoting "Prashanth.S" :
> 
> 
>>I think u can also use eventlisteners which are allmost same thing as
>>filters..
>>Regards
>>Prashanth
>>
>>Kris Schneider wrote:
>>Seems like the easiest thing to do would be to write a Filter mapped to
>>"/*"
>>that uses HttpServletRequest.getRequestURI to capture the requested URI. In
>>a
>>conformant Servler 2.3 container, the Filter will only operate on the
>>original
>>client request, not forwards or includes.
>>
>>Quoting david chan :
>>
>>
>>>Hi,
>>>I am writing a RequestProcessor that is a subclass of
>>>Struts 1.1 RequestProcessor, the purpose is to track
>>>user activities, i.e. which link the user clicked,
>>>which page the user requested etc.
>>>I override the method processForwardConfig, and put
>>>my tracking function first, here is how it looks:
>>>
>>>//my code to log user request
>>>logPage(request.getRequestURI());
>>>super.processForwardConfig(request, response, forward
>>>);
>>>
>>>
>>>However, there is one problem with this approach, 
>>>If there is action chaining (or server side forward),
>>>that will be also logged, but that is not the user
>>>requested URI, and I don't need to log any of chained
>>>action URI or server side forwarded URI. 
>>>
>>>Any suggestion how to deal with this problem?
>>>
>>>Thanks.
>>>David
>>
>>-- 
>>Kris Schneider 
>>D.O.Tech 

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>



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


Re: tracking user activities: how to ignore action chaining (or server side forward)

Posted by "Prashanth.S" <su...@yahoo.com>.
Hi Kris,
I have studied eventlisteners in a book[programming jakarta struts].I think below mentioned url will provide u with the required info.. 
 
http://www.onjava.com/pub/a/onjava/2001/04/12/listeners.html?page=3
 
Thanks
Prashanth

Kris Schneider <kr...@dotech.com> wrote:
I don't really see how event listeners and filters are almost the same thing.
Can you elaborate? Is it possible to provide a customized request or response
object through an event listener? Can event listeners be mapped to either a
specific servlet or URL pattern?

Quoting "Prashanth.S" :

> I think u can also use eventlisteners which are allmost same thing as
> filters..
> Regards
> Prashanth
> 
> Kris Schneider wrote:
> Seems like the easiest thing to do would be to write a Filter mapped to
> "/*"
> that uses HttpServletRequest.getRequestURI to capture the requested URI. In
> a
> conformant Servler 2.3 container, the Filter will only operate on the
> original
> client request, not forwards or includes.
> 
> Quoting david chan :
> 
> > Hi,
> > I am writing a RequestProcessor that is a subclass of
> > Struts 1.1 RequestProcessor, the purpose is to track
> > user activities, i.e. which link the user clicked,
> > which page the user requested etc.
> > I override the method processForwardConfig, and put
> > my tracking function first, here is how it looks:
> > 
> > //my code to log user request
> > logPage(request.getRequestURI());
> > super.processForwardConfig(request, response, forward
> > );
> > 
> > 
> > However, there is one problem with this approach, 
> > If there is action chaining (or server side forward),
> > that will be also logged, but that is not the user
> > requested URI, and I don't need to log any of chained
> > action URI or server side forwarded URI. 
> > 
> > Any suggestion how to deal with this problem?
> > 
> > Thanks.
> > David
> 
> -- 
> Kris Schneider 
> D.O.Tech 

-- 
Kris Schneider 
D.O.Tech 

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



---------------------------------
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

Re: tracking user activities: how to ignore action chaining (or server side forward)

Posted by Kris Schneider <kr...@dotech.com>.
I don't really see how event listeners and filters are almost the same thing.
Can you elaborate? Is it possible to provide a customized request or response
object through an event listener? Can event listeners be mapped to either a
specific servlet or URL pattern?

Quoting "Prashanth.S" <su...@yahoo.com>:

> I think u can also use eventlisteners which are allmost same thing as
> filters..
> Regards
> Prashanth
> 
> Kris Schneider <kr...@dotech.com> wrote:
> Seems like the easiest thing to do would be to write a Filter mapped to
> "/*"
> that uses HttpServletRequest.getRequestURI to capture the requested URI. In
> a
> conformant Servler 2.3 container, the Filter will only operate on the
> original
> client request, not forwards or includes.
> 
> Quoting david chan :
> 
> > Hi,
> > I am writing a RequestProcessor that is a subclass of
> > Struts 1.1 RequestProcessor, the purpose is to track
> > user activities, i.e. which link the user clicked,
> > which page the user requested etc.
> > I override the method processForwardConfig, and put
> > my tracking function first, here is how it looks:
> > 
> > //my code to log user request
> > logPage(request.getRequestURI());
> > super.processForwardConfig(request, response, forward
> > );
> > 
> > 
> > However, there is one problem with this approach, 
> > If there is action chaining (or server side forward),
> > that will be also logged, but that is not the user
> > requested URI, and I don't need to log any of chained
> > action URI or server side forwarded URI. 
> > 
> > Any suggestion how to deal with this problem?
> > 
> > Thanks.
> > David
> 
> -- 
> Kris Schneider 
> D.O.Tech 

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

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


Re: tracking user activities: how to ignore action chaining (or server side forward)

Posted by "Prashanth.S" <su...@yahoo.com>.
I think u can also use eventlisteners which are allmost same thing as filters..
Regards
Prashanth

Kris Schneider <kr...@dotech.com> wrote:
Seems like the easiest thing to do would be to write a Filter mapped to "/*"
that uses HttpServletRequest.getRequestURI to capture the requested URI. In a
conformant Servler 2.3 container, the Filter will only operate on the original
client request, not forwards or includes.

Quoting david chan :

> Hi,
> I am writing a RequestProcessor that is a subclass of
> Struts 1.1 RequestProcessor, the purpose is to track
> user activities, i.e. which link the user clicked,
> which page the user requested etc.
> I override the method processForwardConfig, and put
> my tracking function first, here is how it looks:
> 
> //my code to log user request
> logPage(request.getRequestURI());
> super.processForwardConfig(request, response, forward
> );
> 
> 
> However, there is one problem with this approach, 
> If there is action chaining (or server side forward),
> that will be also logged, but that is not the user
> requested URI, and I don't need to log any of chained
> action URI or server side forwarded URI. 
> 
> Any suggestion how to deal with this problem?
> 
> Thanks.
> David

-- 
Kris Schneider 
D.O.Tech 

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



---------------------------------
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

Re: tracking user activities: how to ignore action chaining (or server side forward)

Posted by Kris Schneider <kr...@dotech.com>.
Seems like the easiest thing to do would be to write a Filter mapped to "/*"
that uses HttpServletRequest.getRequestURI to capture the requested URI. In a
conformant Servler 2.3 container, the Filter will only operate on the original
client request, not forwards or includes.

Quoting david chan <da...@yahoo.com>:

> Hi,
>  I am writing a RequestProcessor that is a subclass of
> Struts 1.1 RequestProcessor, the purpose is to track
> user activities, i.e. which link the user clicked,
> which page the user requested etc.
>  I override the method processForwardConfig, and put
> my tracking function first, here is how it looks:
> 
> //my code to log user request
> logPage(request.getRequestURI());
> super.processForwardConfig(request, response, forward
> );
> 
> 
>  However, there is one problem with this approach, 
> If there is action chaining (or server side forward),
> that will be also logged, but that is not the user
> requested URI, and I don't need to log any of chained
> action URI or server side forwarded URI. 
> 
>  Any suggestion how to deal with this problem?
> 
> Thanks.
> David

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

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


Re: tracking user activities: how to ignore action chaining (or server side forward)

Posted by Pirmez <pi...@snap.com.br>.
Hi David,

Try request.getRequestURL()

david chan escreveu:
> Hi,
>  I am writing a RequestProcessor that is a subclass of
> Struts 1.1 RequestProcessor, the purpose is to track
> user activities, i.e. which link the user clicked,
> which page the user requested etc.
>  I override the method processForwardConfig, and put
> my tracking function first, here is how it looks:
> 
> //my code to log user request
> logPage(request.getRequestURI());
> super.processForwardConfig(request, response, forward
> );
> 
> 
>  However, there is one problem with this approach, 
> If there is action chaining (or server side forward),
> that will be also logged, but that is not the user
> requested URI, and I don't need to log any of chained
> action URI or server side forwarded URI. 
> 
>  Any suggestion how to deal with this problem?
> 
> Thanks.
> David
> 
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com



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