I have a servlet that I want the container to load on startup. However, I do not want anyone to be able to load the servlet from a browser. In other words, I don't want to map the servlet to anything. Is it possible to do this? If I don't provide a servlet-mapping, is it still available from a url by it's name?
Joined: Jul 28, 2002
The answer is no! Yay! OK, if you have:
But no mapping, it WILL be loaded by the container, but will NOT be accessible by any other means. Cool.
Robert The servlet is still accessible from a URL. Defining a servlet mapping is optional, and is simply a means to determine which servlets should handle which URL patterns. Your servlet could be accessed from the browser address window, for instance, with:
I tried that and it didn't work. I can't access my servlet from a browser. I tried doing it like you suggested. i also tried doing it with "webapp/servletname" and not the intermediary "servlet" folder and I still couldn't find it. I can't load the servlet from a url. Why are you still able to? Try checking your web.xml both in the main root and the webapp you're using and also the server config. My webapp files are NOT under the root of my servlet engine's folder. They're elsewhere on the computer and mapped to a specific virtual host.
subject: If Servlet load-on-startup, Does it also need servlet-mapping?