I have manually configured web.xml
for my application. Now, I'm facing issues while running my application. I'm trying to access my servlet
from my jsp
page. But, it is throwing error as page not found
.
The servlets are placed under below folder location
<application folder>/WEB-INF/classes/<package>
So, what should be the entries for servlets in url-pattern
and servlet-mapping
. So that, servlet
can be accessible through URL.
Best Answer
url-pattern
is used inweb.xml
to map yourservlet
to specific URL. Please see below xml code, similar code you may find in yourweb.xml
configuration file.If you change
url-pattern
ofAddPhotoServlet
from/AddPhotoServlet
to/MyUrl
. Then,AddPhotoServlet
servlet can be accessible by using/MyUrl
. Good for the security reason, where you want to hide your actual page URL.Java Servlet
url-pattern
Specification:Reference : Java Servlet Specification
You may also read this Basics of Java Servlet