• Post Reply Bookmark Topic Watch Topic
  • New Topic

Filter Behavior

 
Jay Damon
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on a very old application and have created a filter to intercept user requests in order to ensure every request is validated. However, I have noticed that the filter also intercepts requests for CSS, JavaScript and image files, not just servlets and JSPs as I had anticipated. However, other than a little additional overhead, everything seems to work okay.

I would like to know if this is correct filter behavior? Should the filter intercept everything?

The application server is WebSphere v5.0 The filter mapping is:

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You told it to map everything with:


If you want finer-grained control, you'll need to adjust the URL pattern accordingly.
 
Jay Damon
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way to tell it just to watch for servlets and JSPs or exclude certain types of files? I'm guessing *.jsp would work, for example, for JSPs but what about servlets? Given the state of naming in the current application it would be easier if I could exclude certain types rather than having to include everything I am interested in.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm assuming that the app, being older, doesn't follow modern conventions and use a front controller whose mapping could easily be used to differentiate active requests from those for static resources?

If there are no patterns that differentiate your active requests from your static request, you may have to just punt and do it programmatically (yuk) within the filter.

Do you have the authority to make changes to the existing mappings to add differentiation?
 
Jay Damon
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear, you are correct. This is an old, old application. It does not follow any conventions. There is no front controller but I'm trying to rectify that.

If there are no patterns that differentiate your active requests from your static request, you may have to just punt and do it programmatically (yuk) within the filter.

Can you clarify what you mean here? In the filter, I have tried discarding the requests for .css, .js, etc. files and not pass them on to the FilterChain doFilter method. However, if I do, they apparently do not get served up at all because they are missing when the page is displayed. So I'm not sure what you mean by "programmatically"? Do you mean just pass them on without any other processing?

Theoretically, I can change the mappings, something I also trying to do in addition to adding a front controller. However, since all servlets are currently served by class name , that is going to be a long, arduous process.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jay Damon:
Do you mean just pass them on without any other processing?

Yes.
 
Jay Damon
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Bear.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problem, good luck with your project. If you need any help bringing it up-to-date, you know where to turn!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!