I have a directory called ./welcome/ and ./welcome/ has a file called ./index.jsp.
I know how to tell jetty or tomcat how to start at ./wecome/index.jsp. But, I also have lots of other directories with an ./index.jsp like --- ./blogs/, ./whatever/, etc.
Without using servlets, is there a way to tell jetty or tomcat, "hey, whenever you get a request for a directory, see if there is an ./index.jsp -- and display it to the user."
Like if I access ./blogs/ I dont want to see a 404 not found. I want to see the contents of ./blogs/index.jsp, but I dont want my users to be redirected to ./blogs/index.jsp -- I want their browsers to still only display ./blogs/
I know apache has such as feature. Any help would be appreciated, thanks.
"hey, whenever you get a request for a directory, see if there is an ./index.jsp -- and display it to the user."
That's exactly what welcome-file-list
is supposed to do.
Simply add the following to web.xml. In this case, first the container will try index.html
and if it does not exist, then it will try index.jsp
.
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
I've tested this on Tomcat 5.5, and it works correctly.
Unfortunately, it's really hard to find the official reference for web.xml. So here is the documentation for Oracle weblogic instead; I think it can be trusted...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With