servlet-filters

Java Filters Performance Question

I have two questions. The first is do Filters add a lot of overhead to request. We have a filter and it is set to run on the URL pattern /*. This means it also runs on all the image request. I think that this is not good for performance, but my co-workers think that it doesn't matter if the filter runs 5 or 6 times per request becaus...

j2ee webapp A using authentication facility of web app B

Any user that tries to access some secure resources on my webapp A needs to be authenticated with a webapp B. B has access to the user credentials password etc., I am wondering about the right way to go about this. One alternative would be to have a filter protecting my secure pages. If a user that is unauthenticated access A secure res...

Servlet filter for browser caching?

Does anyone know how to go about coding a servlet filter that will set cache headers on a response for a given file/content type? I've got an app that serves up a lot of images, and I'd like to cut down on bandwidth for hosting it by having the browser cache the ones that don't change very often. Ideally, I'd like to be able to specify...

jsf sevlet-mapping for *.jsp

Is there a way I can tell my application to let every single page (let's say .jsp pages) to go under faces context? In my web.xml I easly can do a servlet-mapping similar to: <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Faces...

Is it possible to forward or redirect from a servlet filter after the response has been comitted?

The logic is that the filter gets hit, the condition is not true, so it goes through the filter chain. After the response is committed, the filter gets hit, and the condition is now true (a request attribute was set). It goes in to execute the forward, but the page never forwards. I know this has something to do with the response being c...

mixing static html pages and JSPs

Hi, I ran into something that I never thought of before and it stumped me. I have a site done using servlets and JSPs. There is an auth mechanism that works well and is much liked. There is now the need to add a static directory containing static HTML pages under the same umbrella. The requirement is that these pages should not be con...

Filter mapping url-pattern that excludes subdirectories

Is there any way to make a filtermapping not include subdirectories? For example. I have .xhtml files in my context root, and I also have a subfolder named "test" with files with the same extension. Is there any may to map a filter to the files in context root and not to the files in the "test" directory? ...

Cannot gzip excluded sitemesh pages

In a servelt application, I've added a Gzip filter (/*, REQUEST) and config it be the first in the filter chain. It works fine with Sitemesh's filter (/*, REQUEST, FORWARD) except that when the request is excluded as specified in deocorators.xml (e.g. for ajax request), the gzip filter throws an illegal state. The gzip filter comes from...

How do I get servlet filters to stop loading on application startup in Tomcat?

Below is my deployment descriptor. I'm using Spring MVC, but I've got a url rewrite filter in place that is supposed to run, and then forward to the appropriate controller. For some reason this filter is loading on startup, trying to get the path translated, and throwing a nullpointerexception because there is no path. I never knew filte...

Why use a Url Rewrite Filter in Spring?

A Spring app I'm using declares a Tuckey UrlReWrite Filter and then sets up a rewrite rule as the following: <rule> <from>^/(.*)$</from> <to last="true">/app/$1</to> </rule> Why do this? Will Spring not be able to recognize requests that do not go to the /app/ url? Otherwise what is the advantage of this redirect? ...

Server-wide functionality across several web applications

I need to perform pre- and post-processing of all incomming requests to a web server. The functionality is both url-level access restriction and language translation but also other special cases that need to be handled globaly. Typically this can be achieved with servlet filters but when the number of web applications grow it becomes de...

JAX-WS servlet filter exceptions

I have a client/server application that communicates via SOAP. The server-side application is a JEE app that exposes web services using JAX-WS. I have a servlet filter setup to perform certain checks before a service is invoked. This is all working pretty well, except for exception handling. If I throw an exception from the filter, i...

Howto: Intercept a a4j request using a javax.servlet.Filter?

Does anybody know how to intercept a a4j request using a javax.servlet.Filter? The interception must occur before FacesServlet be called (it's why I'm planing to do it using Filter). I'd like to know wich method will be executed on my backbean, cause I need to do a dynamic control first. Tks! ...

X-JSON servlet filter:GA

Hello I have a specific need to filter out the X-JSON header attribute and its data content. It is actually my first foray into servlet filters so it is a general audience question. I have investigated the structure of the filter api. What I do not understand is how, I believe, in the HTTPServletResponseWrapper I filter for a custom a...

Orchestra and RichFaces problem

I use Orchestra and RichFaces in my application. When accessing a page in my application I get the following error many times and the page doesn't load: WARN _ReentrantLock:103 - Waited for longer than 30000 milliseconds for access to lock org.apache.myfaces.orchestra.lib._ReentrantLock@78214f6b which is locked by thread http-8080-2 I...

What's recommended for authentication check? Servlet Filters or Form based authentication?

We are working implementing Single Sign On(SSO) using pingfederate. The basic implementation uses a login token sent via browser cookies for checking user authentication. What's the recommended way of doing the authentication check? Should I use a login filter or configure form-based authentication? ...

Grails filters: Any way of chaining filters?

Hi, is there a way to chain several filters in a grails application (as in Java filters)? Maybe something with spring? I've written a couple of filters, and would like to get them to execute serially (order is not particularly important), and I need some help on achieving this. The reason behind? I need to write about 20, 30 filters, a...

Infinite loop when using filter for jsp files

When I make filter for all jsp pages, the browser goes into an infinite loop, but when I make filter for only one page, it runs correctly!! Here is doFilter method, if some one find the error plx tell me... public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletExce...

Using some beans in Filter bean class ?

Hi all, In my filter bean class, I added some beans dependancy (with @Autowired annotation). But in the method doFilter(), all my dependancy beans have null ... public class FacebookOAuth implements Filter { @Autowired private BusinessLogger logger; @Autowired private IUserSessionInfo userSessionInfo; @Autowired private FacebookOAuth...

creating a filter in my spring mvc application using IDE

I'm trying to create a filter, for some reason I am not seeing autocompletion when I create a class that implements a Filter. When I type: import javax.servlet IDEA doesn't seem to pickup the namespace. Is this a separate .jar that I have to setup in maven? Update My filter mappings look like: <filter> <filter-name>perfo...