Let us assume two servlets defined in web.xml and corresponding <load-on-startup> attribute. Which one of the servlet will be loaded in memory first at the time of server startup?

<servlet>
  <servlet-name>AuthenticationServlet</servlet-name>
  <display-name>AuthenticationServlet</display-name>
  <servlet-class>com.modernpathshala.AuthenticationServlet</servlet-class>         
  <load-on-startup>2</load-on-startup>
</servlet>

<servlet>
  <servlet-name>AuthorizationServlet</servlet-name>
  <display-name>AuthorizationServlet</display-name>
  <servlet-class>com.modernpathshala.AuthorizationServlet</servlet-class>
  <load-on-startup>3</load-on-startup>
</servlet>

Solution

Servlet will lower value of load-on-startup attribute/tag is loaded first. Hence, AuthenticationServlet will be loaded first and then AuthorizationServlet will be loaded.

Share this thread

Comments

Comments
comments powered by Disqus

Navigation

Social Media