wood burning stoves 2.0*
The moose likes Servlets and the fly likes Setting up a servlet filter mapping on welcome file in web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Setting up a servlet filter mapping on welcome file in web.xml" Watch "Setting up a servlet filter mapping on welcome file in web.xml" New topic
Author

Setting up a servlet filter mapping on welcome file in web.xml

Choon-Chern Lim
Ranch Hand

Joined: Aug 29, 2005
Posts: 74
I have an web application, where when user enters http://server/app, it will be mapped directly to http://server/app/index.do



In this application, I'm also setting up a filter to intercept all user requests, making sure they are right authentication to the application. Basically, I'm intercepting all the *.do signature because I'm using Struts.



I have tested this filter and it works if the URL has this signature: http://server/app/*.do. However, it doesn't catch the welcome file's signature (http://server/app).

I tried different url pattern such as / or /* and the filter is still unable to intercept request coming from http://server/app.

How do I go about fixing this?

Thanks.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

What container are you using?

I don't know the answer to your question but, for kicks, try creating an empty file named "index.do" in the root directory of your app.


I just tried this in Tomcat 55 and it it worked.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Choon-Chern Lim
Ranch Hand

Joined: Aug 29, 2005
Posts: 74
I'm running in the servlet container in WAS 6.

Anothe way I could do is to have /app mapped to /index.jsp (instead of the *.do) in the web.xml, and then have index.jsp auto-redirect to index.do.

The reason I can't create an empty index.do file is because every *.do signature is also handled Struts action servlet.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Why would that keep you from creating an empty index.do file?
Choon-Chern Lim
Ranch Hand

Joined: Aug 29, 2005
Posts: 74
I just tried creating an empty index.do right under the app root, but the filter couldn't intercept it either.
Choon-Chern Lim
Ranch Hand

Joined: Aug 29, 2005
Posts: 74
I just tried creating an empty index.do right under the app root, but the filter couldn't intercept it either.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Look at SRV.6.2.5
And try adding a <dispatcher> element to your mapping for Forwards.



[ August 07, 2006: Message edited by: Ben Souther ]
Choon-Chern Lim
Ranch Hand

Joined: Aug 29, 2005
Posts: 74
Yup.. not working either... I even tried /* and did print out on the request URI so that I know what's being caught, but even /* is not intercept my welcome file.... jeezzz
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Sorry, edited the last one but got pulled away before posting.
Look up ^
Choon-Chern Lim
Ranch Hand

Joined: Aug 29, 2005
Posts: 74
Ben, the "jeezzz" is my out of frustration on the problem, not on you.

I have decided to use a html redirection to handle this issue and have the html set up as the welcome file.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

No, I meant, look up.
I started to edit the post (the one that suggested using "/") but got distracted before hitting send.
So, before I could send it, you responded.

Read up 3 posts from this one.
 
GeeCON Prague 2014
 
subject: Setting up a servlet filter mapping on welcome file in web.xml