This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in simple Filter servlet Program

 
Parthiban Malayandi
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64185
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Amit Ghorpade
Bartender
Posts: 2851
10
Fedora Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • 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: 2851
10
Fedora Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64185
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic