Jerome,

   Excellent!  Fantastic!  I will try it, thank you so much.

Dustin


Jerome Louvel wrote:
Hi Dustin,

The WAR client is automatically installed when you use the ServerServlet
adapter. In Restlet 1.1, this will work with the standalone mode too, so
Application portability will be intact.

So, you can already simplify your code like this:

    public Representation getRepresentation(final Variant variant)
    {
        return getContext().getDispatcher()
                .get("war:///css/{cssfile}").getEntity();
    }

Note that going through the context's dispatcher lets you transparently
reuse request's attributes via URI templates :)

Let me know if this works for you.

Best regards,
Jerome
-----Message d'origine-----
De : Dustin N. Jenkins [mailto:[EMAIL PROTECTED] Envoyé : mardi 12 juin 2007 16:19
À : Discussion about Restlet
Objet : Best way to serve CSS and Javascript from a WAR?

I'm deploying my Restlet application into a WAR in Tomcat, and everything seems to be working just fine. Normally, it'd be nicer to simply let Tomcat handle the CSS and Javascript files, but I want to map everything (/*) to the ServerServlet so I can keep the initial part of the resource ref (i.e. if I were to map /abc/* and /xyz/* I wouldn't be able to match those because it becomes the base ref and gets stripped off). Here's what I'm doing now for the CSSResource that the /css/{cssfile} is routed to:
    public Representation getRepresentation(final Variant variant)
    {
        final ServletWarClient warClient =
                new ServletWarClient(getContext(),
((ServletContextAdapter) getContext()).getServletContext());

        return warClient.get("war:///css/"
+ getRequestAttribute("cssfile")).getEntity();
    }

Which isn't elegant at all as it's tuned specifically to being deployed as a WAR, and can no longer be run as a standalone, not to mention all the implementation specific stuff... Is there a better way? I know normal static stuff is served via the Directory resource, but it doesn't apply here because everything is inside the WAR.
Any suggestions?
Thank you for the fantastic framework!

Dustin

--


Dustin N. Jenkins | Tel/Tél: 250.363.3101 | [EMAIL PROTECTED]

facsimile/télécopieur: (250) 363-0045

National Research Council Canada | 5071 West Saanich Rd, Victoria BC. V9E 2E7

Conseil national de recherches Canada | 5071, ch. West Saanich, Victoria (C.-B) V9E 2E7

Government of Canada | Gouvernement du Canada

Reply via email to