B4J Question Jetty Server - Prevent a folder from display

hatzisn

Expert
Licensed User
Longtime User
Good morning everyone,

Let's imagine we are creating a webapp with jetty server and under "www" folder we have a folder named "img" for images. If I navigate to http://localhost:{port}/img. It displays a list with the files apparent there. I found out that if I place an empty html page (<html><body></body></html>) in this folder and name it index.html it displays this page and does not display the incredients of the folder. Is there a better way to do this?
 

teddybear

Well-Known Member
Licensed User
You can add a handler specifically to handle the path and make it respond with 404

B4X:
srvr.AddHandler("/img/", "ImgPathProcess", False)
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Add this line:
B4X:
srvr.SetStaticFilesOptions(CreateMap("dirAllowed": False))
 
Upvote 0
Top