Reputation: 451
I have a servlet:
@WebServlet ("/*")
public class X extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
System.out.println("1");
}
}
I cannot figure out why it prints "1" twice. Who can explain that?
Output:
1
1
Upvotes: 1
Views: 57
Reputation: 1307
You can print out
request.getRequestURI()
to confirm the URLs for the two requests.
Upvotes: 1
Reputation: 645
It may because of your servlet annotation.
@WebServlet ("/*")
try with this
@WebServlet( displayName="Notification Servlet", urlPatterns = {"/yourservletpath"})
Upvotes: 0
Reputation: 93
A browser send 2 requests. 1 is your GET request and the 2nd one is an attempt to retrieve the favicon.
Upvotes: 0