I’m a beginner with Tomcat/Java; I have a simple web application for which I would like to show a different <welcome-file> in web.xml depending on whether the application is being run locally development or deployed live.
Right now I have:
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
For local development I would like the <welcome-file> in web.xml to be index-dev.html for development and index-live.html for the deployed live application. Reason being I want to load different *.css and *.js depending on whether I’m local or live.
Any way in which I can achieve this setup?
As an option: make a jsp file as a welcome page.
In that jsp file analyze current client location (local computer or not), and forward to the relevant page.
ADDITIONAL EDIT:
Your jsp has a predefined
requestobject.Use it to get client ip, like that:
Compare it with localhost address, which can be obtained via:
And use
jsp:forwardto forward to a relevant page.Additional edit:
Make sure that localhostIp contains only IP address, otherwise use
Stringmethods to get substring with ip-address inside.