Tomcat directly serve static (css, js) files shared by multiple applications

42

I'm running a RESTful web service that serves some static content stored in a directory outside of Tomcat. The directory is specified by a servlet parameter in web.xml You could do something similar and just specify an absolute path to the files you need - place them in Tomcat somewhere or wherever road you like. I can post some sample code if you like. Of course all other files that reference the javascript and CSS would need to change because these files will be at a different URL directory than the web apps that use them. For instance, src="restAppContextName/serve/youJavaScript.js" where serve is a @Path for the REST web service and whatever follows is a @PathParam. To the browser, /serve will be treated like it's a directory, so a relative reference from one js file to another should work.

Share:
42

Related videos on Youtube

Kumar Gaurav
Author by

Kumar Gaurav

Updated on September 18, 2022

Comments

  • Kumar Gaurav
    Kumar Gaurav over 1 year

    I am developing an App which works much like a social network in which you download images show comments etc.

    Problem: I show images using RecyclerView and CardView. Hence images gets downloaded when they actually renders. My problem is if user scrolls down to multiple images all of them gets queued to download and if that time someone taps to view comments, it waits until queued images gets downloaded. Although downloading comments will take much less time still my user has to wait.

    Is there anyway i can prioritize these http requests so that user gets first what they need

  • Joseph Victor Zammit
    Joseph Victor Zammit almost 12 years
    Thank you for your help, I got around it in a different way (updated the question with the "solution". +1'ed your answer since it still is valuable feedback.