aspose file tools*
The moose likes Servlets and the fly likes If Servlet load-on-startup, Does it also need servlet-mapping? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "If Servlet load-on-startup, Does it also need servlet-mapping?" Watch "If Servlet load-on-startup, Does it also need servlet-mapping?" New topic
Author

If Servlet load-on-startup, Does it also need servlet-mapping?

Robert Paris
Ranch Hand

Joined: Jul 28, 2002
Posts: 585
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?
Robert Paris
Ranch Hand

Joined: Jul 28, 2002
Posts: 585
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.
Mark Howard
Ranch Hand

Joined: Feb 14, 2001
Posts: 285
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:
Robert Paris
Ranch Hand

Joined: Jul 28, 2002
Posts: 585
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: If Servlet load-on-startup, Does it also need servlet-mapping?