Reputation: 556
I've mapped my servlet in this way in the web.xml:
<servlet>
<servlet-name>home</servlet-name>
<servlet-class>servlet.HomeServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>home</servlet-name>
<url-pattern>/HomeServlet</url-pattern>
</servlet-mapping>
And I'm trying to call this:
<a href="/HomeServlet" class="brand"><img alt="logo" src="img/Logo2.png"></a>
But when I click on the link I get this error
HTTP Status 404 - /HomeServlet
type Status report
message /HomeServlet
description The requested resource (/HomeServlet) is not available.
What is wrong?
Upvotes: 0
Views: 136
Reputation: 85799
You need to add the name of your context before /HomeServlet
. If you're using JSP, you can solve this using ${pageContext.request.contextPath}
:
<a href="${pageContext.request.contextPath}/HomeServlet" class="brand"><img alt="logo" src="img/Logo2.png"></a>
Upvotes: 1