more on servlet filters 2...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

more on servlet filters 2...

sent2null@netzero.com
In the message transcribed below I requested help getting filters to work. I've since cobbled together what I think should work. It compiles but the defined filter's "doFilter()" doesn't seem to be called.

Here's the block of code that initializes the WebContextHandler and Filter:

********************code below

...
initialize server object, define listeners, get httpcontext
...

System.out.println("just before defining authorization filter code block, http context.");
             //Instantiate a new webapplicationhandler
             WebApplicationHandler whandler = new WebApplicationHandler(); //context.getWebApplicationHandler();
             //Instantiate a filter holder
             FilterHolder fholder = whandler.defineFilter("authfilter",AuthorizationFilter.class.getName());
             //add the filterholder to the webapp handler after defining it for the authorization filter.
             whandler.addFilterHolder(fholder/*"Entegra.Publish.AuthorizationFilter"*/);
             //Map context path to the filter
             whandler.addFilterPathMapping(cono.getVirtualPath(),"authfilter",Dispatcher.__REQUEST);
             //add the webapphandler to the existing server context
             context.addHandler(whandler);
              System.out.println("just after adding authorization filter handler to context, http context.");
         
...
define servletHandler and add servlets, define resourcehandler,start server
...


********************code above

I am investigating using a WebApplication context for the server instead of the HttpContext, any additional help would be appreciated.

Regards,

David






**********************************previous letter******************

Subject: [jetty-discuss] Using Servlet Filters programmatically.
Reply-To: [hidden email]

I am using Jetty as a servlet context and want to use filters without using the xml configuration file that is programatically. How do I associate or invoke a created Filter with a running Jetty server loaded with contexts once requests come in on those contexts?

Any help with this issue would be greatly appreciated.

Regards,

David


______________________________________________________________________
Revolutionize the way you surf the Web!
Try NetZero HiSpeed 3G.
Visit http://www.netzero.com to sign up today!




--__--__--

_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss


End of jetty-discuss Digest



______________________________________________________________________
Revolutionize the way you surf the Web!
Try NetZero HiSpeed 3G.
Visit http://www.netzero.com to sign up today!



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: more on servlet filters 2...

Greg Wilkins-5

What does cono.getVirtualPath() return?

Try putting "/*" as the filter path, so it applies to all requests.

cheers


[hidden email] wrote:

> In the message transcribed below I requested help getting filters to work. I've since cobbled together what I think should work. It compiles but the defined filter's "doFilter()" doesn't seem to be called.
>
> Here's the block of code that initializes the WebContextHandler and Filter:
>
> ********************code below
>
> ....
> initialize server object, define listeners, get httpcontext
> ....
>
> System.out.println("just before defining authorization filter code block, http context.");
>              //Instantiate a new webapplicationhandler
>              WebApplicationHandler whandler = new WebApplicationHandler(); //context.getWebApplicationHandler();
>              //Instantiate a filter holder
>              FilterHolder fholder = whandler.defineFilter("authfilter",AuthorizationFilter.class.getName());
>              //add the filterholder to the webapp handler after defining it for the authorization filter.
>              whandler.addFilterHolder(fholder/*"Entegra.Publish.AuthorizationFilter"*/);
>              //Map context path to the filter
>              whandler.addFilterPathMapping(cono.getVirtualPath(),"authfilter",Dispatcher.__REQUEST);
>              //add the webapphandler to the existing server context
>              context.addHandler(whandler);
>               System.out.println("just after adding authorization filter handler to context, http context.");
>          
> ....
> define servletHandler and add servlets, define resourcehandler,start server
> ....
>
>
> ********************code above
>
> I am investigating using a WebApplication context for the server instead of the HttpContext, any additional help would be appreciated.
>
> Regards,
>
> David
>
>
>
>
>
>
> **********************************previous letter******************
>
> Subject: [jetty-discuss] Using Servlet Filters programmatically.
> Reply-To: [hidden email]
>
> I am using Jetty as a servlet context and want to use filters without using the xml configuration file that is programatically. How do I associate or invoke a created Filter with a running Jetty server loaded with contexts once requests come in on those contexts?
>
> Any help with this issue would be greatly appreciated.
>
> Regards,
>
> David
>
>
> ______________________________________________________________________
> Revolutionize the way you surf the Web!
> Try NetZero HiSpeed 3G.
> Visit http://www.netzero.com to sign up today!
>
>
>
>
> --__--__--
>
> _______________________________________________
> jetty-discuss mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jetty-discuss
>
>
> End of jetty-discuss Digest
>
>
>
> ______________________________________________________________________
> Revolutionize the way you surf the Web!
> Try NetZero HiSpeed 3G.
> Visit http://www.netzero.com to sign up today!
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads, discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss