views:

42

answers:

1

I want to have a web app and then configure it to load static files from a direct path.

This is the webapp configuration:

<Context docBase="E:\webapp1" path="/" reloadable="true"/>

How do I setup the static resources.

+2  A: 

I assume your Tomcat already can run at http://localhost:8080/

All you need to do then is to put your static resources in sub-folders of

E:\webapp1

like

E:\webapp1\jpg\1.jpg
E:\webapp1\css\style.css
E:\webapp1\html\abc.html

Change the path in Context to "" so this webapp can run as the default webapp i.e. the webapp name will not be part of the URL

and you can directly serve these as

http://localhost:8080/jpg/1.jpg
http://localhost:8080/css/style.css
http://localhost:8080/html/abc.html

Is this what you were looking for? This is my understanding of your question

JoseK
I gave you an up-vote because I didn't know if you set the context to blank it becomes the default context. What happens if there are two blank context's?
Koekiebox
@Koekiebox: Tomcat refuses to start up. **WARNING: Catalina.start using conf/server.xml: java.lang.IllegalArgumentException: addChild: Child name '' is not unique**
JoseK