I have a java web project myapp running on tomcat 8 my html file is in myapp/app/index.html But i dont want the app to be seen in the url - just myapp/index.html How can this be done
Asked
Active
Viewed 651 times
2 Answers
0
You can use the rewrite Valve.
myapp/
app/index.html
META-INF/context.xml <-- add
WEB_INF/
rewrite.config <-- add
web.xml
context.xml:
<?xml version="1.0" encoding="utf-8"?>
<Context>
<Valve className="org.apache.catalina.valves.rewrite.RewriteValve"/>
</Context>
rewrite.config:
RewriteRule ^/index.html /app/index.html
RewriteRule ^/$ /app/index.html

xiaofeng.li
- 8,237
- 2
- 23
- 30
-
Where and how do i add it ? – yonia Jan 07 '15 at 12:27
-
I created a minimal webapp that works. Note that you should remove `index.jsp` from your app root. – xiaofeng.li Jan 07 '15 at 12:50
-
it doesnt seems to work nothing happens when i go to http://localhost:8080/app/index.html – yonia Jan 07 '15 at 12:58
-
Well...you should access localhost:8080/myapp/index.html – xiaofeng.li Jan 07 '15 at 13:00
-
It doesnt seems to handle the request – yonia Jan 07 '15 at 13:03
0
Or you could run your app in the root context of tomcat:

Community
- 1
- 1

Thomas Steinbach
- 1,019
- 1
- 9
- 19
-
-
The obvious solution to that problem, to copy the web resources to the webapp root folder, is not acceptable I guess? Why are they in an 'app' subfolder? To maintain an easier to manage hierarchy for development perhaps? – Gimby Jan 07 '15 at 13:10
-