0

one is under ROOT as webapps/ROOT/jsp/error.jsp and other is under webapps/documents/jsp/errorpage.jsp and my web.xml entry is as follows

<servlet>
    <servlet-name>ErrorPage</servlet-name>
    <servlet-class>org.apache.jsp.jsp.error_jsp</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>ErrorPage</servlet-name>
    <url-pattern>/jsp/errorpage.jsp</url-pattern>
</servlet-mapping>

In general web.xml contains servlet and servlet-mapping entry. servlet-mapping entry contains the url and servlet entry contains the servlet path upto my understanding.

I couldn't understand the above entry in web.xml. Please help me know about it.

1 Answers1

0

From Servlet Specification: The servlet-class element contains the fully qualified class name of the servlet.

You specify to the container (tomcat) that: org.apache.jsp.jsp.error_jsp is the fully qualified class name of a Servlet called ErrorPage.

From Servlet Specification: The servlet-mappingType defines a mapping between a servlet and a url pattern.

You specify to the container that requests with url /jsp/errorpage.jsp must be responded by server ErrorPage.

Example:

tomcat receives a first (i.e. first request to the servlet since app start) HTTP GET request having url /jsp/errorpage.jsp;

tomcat loads the class org.apache.jsp.jsp.error_jsp, creates an instance of the class, initializes the servlet and than calls the doGet() method of the servlet.

mrtexaz
  • 663
  • 7
  • 22