You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Hardee, Tony" <To...@ps.net> on 2001/02/15 18:55:05 UTC

Snoop

In a previous model 2 framework that I used there was the ability to snoop
requests.  Basically any request that had the parameter snoop=3 (where 3
represents the depth level) was routed to a snoop jsp that generated an html
page using java reflection.  It displayed the contents of the request
(including data from the model) state.  This allowed the controller and
model components (e.g., Actions) to be developed and tested without a view
component. 

I don't believe that struts has such a feature.  If this is correct, could
someone provide guidance as to a proper way to extend struts (e.g., specific
method in the ActionServlet to override, etc.) to introduce this
functionality.

Tony Hardee

-----Original Message-----
From: Hardee, Tony [mailto:Tony.Hardee@ps.net]
Sent: Thursday, February 15, 2001 11:31 AM
To: 'struts-user@jakarta.apache.org'
Subject: Where are log messages going?


I have a modified version of the example application running in WebLogic
6.0.  In the servlet configuration I have the following debug init
parameter:

    <init-param>
      <param-name>debug</param-name>
      <param-value>1</param-value>
    </init-param>

Unfortunately, I do not see any of the log messages from Struts.  What else
do I need to do?

Tony Hardee

Re: Snoop

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
"Hardee, Tony" wrote:

> In a previous model 2 framework that I used there was the ability to snoop
> requests.  Basically any request that had the parameter snoop=3 (where 3
> represents the depth level) was routed to a snoop jsp that generated an html
> page using java reflection.  It displayed the contents of the request
> (including data from the model) state.  This allowed the controller and
> model components (e.g., Actions) to be developed and tested without a view
> component.
>
> I don't believe that struts has such a feature.  If this is correct, could
> someone provide guidance as to a proper way to extend struts (e.g., specific
> method in the ActionServlet to override, etc.) to introduce this
> functionality.
>

You are correct that Struts does not have such a feature at the moment.  If I
were to subclass and add this functionality, I would do override the process()
method -- which handles every single request through the controller servlet --
as follows:

    protected void process(HttpServletRequest request,
        HttpServletResponse response) throws IOException, ServletException {

        ... write my snoop output here ...
        super.process(request, response);

    }

You could also intercept and dump things at several other points, by overriding
one of the processXxxxx methods instead.  For example, to intercept and dump
after the correct mapping has been selected, you might override processMapping()
instead, and do your logging *after* the superclass processMapping() method has
returned.

If you are running in a servlet 2.3 environment like Tomcat 4.0, you can also
use the new Filter capability to do this without disturbing the application at
all.  Check out the RequestDumperFilter in the "/examples" webapp included with
Tomcat 4.0.  The mapping to enable it is commented out in the web.xml file, but
you can easily uncomment it, or copy this code into your own environment.

> Tony Hardee
>

Craig McClanahan