Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Wildcards in <url-pattern>

Reply
Thread Tools

Wildcards in <url-pattern>

 
 
Edward Patrick
Guest
Posts: n/a
 
      02-25-2004
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
 
Reply With Quote
 
 
 
 
Chris Smith
Guest
Posts: n/a
 
      02-25-2004
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
 
Reply With Quote
 
 
 
 
Ola Gustafsson
Guest
Posts: n/a
 
      02-26-2004
(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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
wildcards ? Martin Bilgrav Cisco 2 09-05-2005 06:24 PM
File names for monitoring must have absolute paths, and no wildcards. msnews.microsoft.com ASP .Net 0 07-18-2004 08:41 PM
DataView filters with wildcards DotNetJunkies User ASP .Net 0 05-24-2004 09:25 PM
Negative Lookbehind and Wildcards Thomas F. O'Connell Perl 1 02-28-2004 01:50 PM
Struts: Using Wildcards in ActionMapping Josh Martin Java 6 11-23-2003 06:06 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57