Berlin Brown
Berlin Brown

Reputation: 11734

Tomcat configuration for development, how to add a webapp, as well as reference static files

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.

Upvotes: 0

Views: 2238

Answers (1)

JoseK
JoseK

Reputation: 31371

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

Upvotes: 3

Related Questions