On 14/06/2019 21:10, Tommy Pham wrote: > Hello everyone, > > I'm trying to write a lightweight and hopefully simple ContextListener + > Servlet application but running into 2 issues I'm unable to find resolution > for and hoping someone would please point me in the right direction: > > 1) I'd like to have Tomcat's default servlet serve HTML files only within > directory /path/ and its' subdirectories. However, I can only get it to > work with this URL mapping "/path/*". My understanding is that the default > servlet will serve any files within /path/. Can this be done with URL path > mapping or do I need to write a custom filter? My servlet's mapping is > "/". Tomcat's default servlet mapping has "/css/*", "/js/*", "/img/*", and > "/path/*".
It depends. If there are alternative mappings (with a higher priority) for all the other static files under /path/* then the DefaultServlet will only serve what is left. A filter might be the cleanest way to ensure you get the behaviour you want. > 2) I Have this small and simple HTML form: > <form method="post"> > <p><input id="text" type="text" size="80"></p> > <p><input type="submit" value="enter"></p> > </form> > My servlet's doPost is triggered but when I iterate the > request.getParameterMap(), it's empty. When I tried to > request.getParameter("text"), it returned 'null'. I do have a filter in > place but it's only to log all request access to a database backend > eventually. That filter is currently dumping it to log. I've tried > disabling the filter but have the same result. You need: <form method="post" enctype="application/x-www-form-urlencoded"> Mark --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org