• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Creating a simple html page filter.

 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've used servlet filters in the past with J2EE apps, but I was wondering if there is anything preventing the same thing from being done on a simple HTML based application.

Assuming the web server supports an up to date servlet spec (and it does...it is the one bundled in the Sun Java App Server 8.1), can you simply add the directories and files you need to get the servlet filter to work, or is there something "special" that might need to be done?

What is there today just looks like this:



What I plan to do is make it look like this:




Will that work? In other words, will the web server know to look at the web.xml file under the WEB-INF directory in this sort of structure, or is something else needed?

Thanks!
[ September 28, 2005: Message edited by: Darrin Smith ]
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Darrin Smith:

What I plan to do is make it look like this:



Will that work? In other words, will the web server know to look at the web.xml file under the WEB-INF directory in this sort of structure, or is something else needed?



I don't think it will work. WEB-INF directory must be under the context root of a web application. If you want to apply your filter to all the subdir[number], you need to create a web app context root directory under docroot of your server like this:



And you just need to add any necessary filter mappings in the web.xml. Hope this helps.
 
Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Heonkoo Lee:


Will that work? In other words, will the web server know to look at the web.xml file under the WEB-INF directory in this sort of structure, or is something else needed?
<hr></blockquote>

I don't think it will work. WEB-INF directory must be under the context root of a web application. If you want to apply your filter to all the subdir[number], you need to create a web app context root directory under docroot of your server like this:



And you just need to add any necessary filter mappings in the web.xml. Hope this helps.[/QB]




Thanks for the feedback.

I was thinking that if this were the ROOT web application then you wouldn't need any context-root. In this case, it is the only application there, but I guess adding a context root above the subdirs is the way to go anyway (I didn't write this originally).

The important thing is that the filter servlet will work with this sort of structure, which is what I was thinking, but wasn't sure of.

Thanks again.
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I don't think it will work. WEB-INF directory must be under the context root of a web application.



The folder containing the WEB-INF folder is the context root of a web application.

All you need to do is define the context in your container's config file. For Tomcat, that would be the config/server.xml file.
 
Heonkoo Lee
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for pointing out you can do that at a container level. I was talking about the web application level in a standard way without modifying server config files.
 
Bear Bibeault
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
P.S. Tomcat 5 also has a new-fangled way of adding contexts without changing server.xml by dropping xml fragments into the right config folder. I haven't had chance to play with it much so the details escape me at the moment -- check out the Tomcat forum which I know has addressed this if interested.
 
A feeble attempt to tell you about our stuff that makes us money
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic