• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem in simple Filter servlet Program

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all ,
I'm new to Servlets .I just studied filtering in Servlets and tried a small program .

Here is the coding



Here is the part of web.xml content for this filter



The problem is Filtering is not working .
I find that doFilter method is not invoked at all when I request "FilterDemo" servlet (which is suppose to be invoked ).
Please tell me what is the problem in that coding .

Thanks in advance
 
Sheriff
Posts: 67746
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
Why are your classes not in packages? That's the first thing to take care of in order to eliminate that as a possible source of error.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes,as beer mentioned above

-------------------------------
<filter-class>FilterLifeCycle</filter-class>
-------------------------------

this should be fully qualified class name.
 
Parthiban Malayandi
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi thanks for your replies .
I tried after put it in to package but still (as previous) filter's init() and destroy() methods alone invoked .
Is anything I'm missing in filter mapping ?
I'm using tomcat 5.5.x series
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by seetharaman venkatasamy:
yes,as beer mentioned above



The name is Bear, serious typo I must say
 
Amit Ghorpade
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I tried after put it in to package but still (as previous) filter's init() and destroy() methods alone invoked .



Why do you think that the doFilter() was not called? What is your output in the browser?
Wasn't the servlet (or the next filter in the chain) invoked?
 
Parthiban Malayandi
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

After struggling for a day I found out the problem .

The problem is due to "Invoker" Servlet.While practicing small programs normally I take advance of using "Invoker" servlet without explicitly providing servlet mapping for each servlet in web.xml that is the problem.

If I do so doFilter method is not invoked where as the requested servlet works perfectly but if I explicitly provide url-pattern for that servlet(or url-pattern for that filter) doFilter method of that Filter is invoked

Thanks to all for your replies
 
Bear Bibeault
Sheriff
Posts: 67746
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
Lesson learned: take no shortcuts even for smaller programs.

But yeah, if you map the filter to a servlet mapping, and then don't use that mapping, no filter will be invoked.
 
reply
    Bookmark Topic Watch Topic
  • New Topic