• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to exclude an url-pattern from servlet-mapping?  RSS feed

 
Kay Gergs
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

I am new to JavaRanch, so hello to everyone!

Today i have run into the following problem.

Given this piece of the web.xml file ...



... all requests will go to front.jsp. That is fine, except that i want to exclude /data/*, which contains images, css-files, ... With the mapping above, a request for an image-file in /data will also go to front.jsp.

Is there a way to say that all requests for /* should go to front.jsp, except the ones for /data/* and that all requests for /data/* should be served without invoking a jsp-file / servlet?

Thank you!

Kay Gergs
[ March 09, 2007: Message edited by: Kay Gergs ]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the servlet container you are using is Tomcat, plain resources are served by the "default" servlet. See the mapping in the base web.xml file in ${tomcat_home}/conf - this is also where .jsp get mapped to the jsp processing servlet etc.

I would try changing the default servlet mapping to /data/* in that web.xml.

Bill
 
Kay Gergs
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by William Brogden:
I would try changing the default servlet mapping to /data/* in that web.xml.


Thank you!

I will try that today.
 
Kay Gergs
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't work.

When i change the default servlet mapping to /data/* or add a mapping to /data/* before or after the default mapping of /, the request for the content of /data/* doesn't go anymore to front.jsp (what is what i want), but the content of /data/* is not served.

I use Tomcat 5.5.20.

Any other idea is greatly appreciated.

Kay Gergs
[ March 10, 2007: Message edited by: Kay Gergs ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66156
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you're going to have a hard time trying to deal with the /* mapping.

And it's rather topsy-tervy. You want to subragate the use of /* for its normal use and use a prefix mapping for that normal use. It's like asking for trouble.

I'd leave /* be, and use a prefix mapping for the front controller.
 
Kay Gergs
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
I'd leave /* be, and use a prefix mapping for the front controller.

Yes, maybe this is what i will do, if there is no other way.

The main purpose for this approach is that i want to hold the URL-String simple.

With the prefix mapping, the url will be something like this:

www.abc.de/application-name/prefix-front-controller/siteXYZ

And without prefix mapping:

www.abc.de/application-name/siteXYZ

What i would prefer most is:

www.abc.de/siteXYZ

I haven't used the appache web-server at this point, but maybe in the connection appache <---> tomcat there is a way to config appache, that it will convert a request-url of

www.abc.de/siteXYZ

to

www.abc.de/application-name/prefix-front-controller/siteXYZ

before it hands over the request-url to tomcat?

That would be great.

Is this possible?

Thank you.

Kay Gergs
[ March 10, 2007: Message edited by: Kay Gergs ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66156
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bending over backwards and adding a lot of complexity, possible fragility and perhaps having to maintain yet another server (Apache) and a connector sounds like a pretty bad trade-off for keeping URLs simple.

And what's the point? The entry URL to your application should be simple, but once they're there, using the navigation provided by your applciation, why do the formats of the URL matter?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!