Is Servlet the default de (de facto) standard?

Related to this is the idea of โ€‹โ€‹a default servlet that serves as standard for static content (even if it's de facto) in servlet containers or does it use limited deployment for Tomcat / Jetty?

For example, 1 shows this method to get the default dispatcher:

final RequestDispatcher rd = getServletContext().getNamedDispatcher("default"); 

From a quick search, it seems that this will also work on Jetty. How widely will this technique work to get the default servlet? For servlet containers that have a default servlet, is it always a static content servlet?

+4
source share
3 answers

This is not a standard, but without it, service applications cannot serve static content. It is very important.

[edit] I saw how you edited and clarified your question more clearly:

For example, [1] shows this method for getting the default dispatcher:

final RequestDispatcher rd =. GetServletContext () getNamedDispatcher ("default");

From a quick search, it seems that this will also work on Jetty. How wide will this technique work to get servlets by default? For servlet containers, which by default servlet, is always the servlet static content?

In this case, it may be the defacto standard, but I would not rely heavily on this and, of course, not on code specific to a particular implementation, or even on defacto standards. Ask yourself: what's the point / value of sending a request to a default servlet? Exactly, nothing.

+4
source

Servlet does not require a default servlet. However, the name must be "default" if one is defined. I can not imagine a container without a servlet by default. Therefore, you can consider this standard.

See section SRV.11.1,

4. If none of the previous three rules leads to a servlet match, the container will try to serve the content corresponding to the requested resource. If the "default" servlet is defined for the application, it will be used.

+2
source

While the servlet container standard is the Servlet API , you can see that there is no such thing as DefaultServlet. The most widely used servlet container has some default values โ€‹โ€‹for starting out of the box. But this is not a โ€œstandardโ€ requirement for implementing a particular interface or abstract class so that the container can work. (A container can work even without a servlet).

0
source

All Articles