aspose file tools*
The moose likes Servlets and the fly likes Servlet filter not getting invoked Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet filter not getting invoked" Watch "Servlet filter not getting invoked" New topic
Author

Servlet filter not getting invoked

Jignesh Gohel
Ranch Hand

Joined: Dec 28, 2004
Posts: 276
I am learning to integrate SSO feature in my web application.I found a tutorial to integrate th CAS(Central Authentication Service)
implementation.

I am using Tomcat 6.0.18.

Please find below the configuration in my web.xml file


As per the tutorial whenever the request for HelloWorldExample( provided by Tomcat ) is sent the page will be redirected to the
CAS Login page.

Problem facing:
If I map the "CAS Filter" using "servlet-name" element "HelloWorldExample" in "filter-mapping" element redirection as mentioned above is working.
In case of using "/*" as the "url-pattern" element the redirection is working.

But in case of "url-pattern" element as "/servlet/*" the page gets redirected to actual JSP page which renders "Hello World".

The "/servlet/*" <url-pattern> should work because it should match the request path for Hello World Example, i.e
http://localhost:8080/examples/servlets/servlet/HelloWorldExample

Can anybody please help me in understanding the cause behind the problem?

Thanks,
Jignesh

Regards,
Jignesh

The Art Of Life Is To Know When To Be Useless And When To Be Useful - CHUANG TZU
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9304
    
  17

Try this



I have only added s to servlet...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Start placing Java classes in packages.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5


ERROR! All classes used in servlets MUST be in a package. The JVM is looking for this class in the "current directory" and not finding it, the servlet instance is never created.

Bill
See the sad story of the Invoker servlet here.
Jignesh Gohel
Ranch Hand

Joined: Dec 28, 2004
Posts: 276
Start placing Java classes in packages.


ERROR! All classes used in servlets MUST be in a package. The JVM is looking for this class in the "current directory" and not finding it, the servlet instance is never created.


I agree, the classes should be created with a proper package structure.But these are the classes provided by Tomcat and not created by me.

I have also gone through the http://faq.javaranch.com/view?InvokerServlet.The article really provides a great insight.Thanks Bill.

Still my query remains unanswered.
When I am using following filter-mapping



the filter does not intercept(i.e the page does not redirect to CAS login page) and the Hello World JSP page is displayed straightaway.

On the other hand following when using following filter-mapping


the filter intercepts and the page is redirected to CAS login page.

In TOMCAT_HOME/conf/web.xml the servlet and servlet-mapping elements for Invoker Servlet are commented out.Thus I suppose it is not the Invoker Servlet which is processing the URL

http://localhost:8080/examples/servlets/servlet/HelloWorldExample.

Then in case of url-pattern "/servlet/*" what is causing the configured filter to not get invoked or intercept the request to HelloWorld.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5
But these are the classes provided by Tomcat


Yes, I see that the Tomcat distribution still comes with servlet examples without a package. A REALLY STUPID IDEA by the Tomcat people left over from the very first servlet container versions.

The problem is that these classes are NOT executed by the normal mapping in web.xml - instead they are executed by the Invoker -

Therefore you can NOT use any parameters, filters, etc in normal web.xml practice with them.

Bill

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet filter not getting invoked