By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,871 Members | 2,418 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,871 IT Pros & Developers. It's quick & easy.

Wildcards in <url-pattern>

P: n/a
Hello,

I would like to have one servlet serve all requests that do not
require any "processing". For example, CSS's, JPG's, etc.

I know I can accomlish this with an entry in WEB.XML:

<servlet-mapping>
<servlet-name>ForwardServlet</servlet-name>
<url-pattern>*.css</url-pattern>
</servlet-mapping>
However; here's my problem. Let's say a page has the following:

<LINK rel=stylesheet type="text/css" href="style.css">

Now, since there is no mapping then "style.css" must reside in the
root. However; I can have my servlet search for "style.css". Let's
say it finds it at "MyApp/ThisClient/style.css".

So, my servlet adds the path and then forwards it on.

However; since WEB.XML says "*.css", well, now my request with
"MyApp/ThisClient/style.css" gets caught too.

The result is an endless loop until the server dies.

Is there any way around this?

I want the css file caught by WEB.XML the first time, after I build
the full path, I just want to serve it.

Any help out there?

Thanks,
Ed
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Edward Patrick wrote:
However; here's my problem. Let's say a page has the following:

<LINK rel=stylesheet type="text/css" href="style.css">

Now, since there is no mapping then "style.css" must reside in the
root. However; I can have my servlet search for "style.css". Let's
say it finds it at "MyApp/ThisClient/style.css".

So, my servlet adds the path and then forwards it on.

However; since WEB.XML says "*.css", well, now my request with
"MyApp/ThisClient/style.css" gets caught too.

The result is an endless loop until the server dies.

Is there any way around this?


You could consider using a filter instead. The first time through,
you'd catch the request and set an attribute in it that it's being
handled. Every other time through, you'd see that attribute and pass it
right through.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Jul 17 '05 #2

P: n/a
EP******@alldata.net (Edward Patrick) writes:

<snip>
So, my servlet adds the path and then forwards it on.

However; since WEB.XML says "*.css", well, now my request with
"MyApp/ThisClient/style.css" gets caught too.


<snip>

Hi

When you say you forward it, I take it you mean that you use sendRedirect.
If that's the case, the easiest way to solve your problem is to use
a request-dispatcher to forward instead:

RequestDispatcher rd = request.getRequestDispatcher(
"MyApp/ThisClient/style.css");
rd.forward(request,response);

HTH
HAND
--
Ola Gustafsson
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.