The problem is that the servlet can't include response from another one. Well, I have one servlet called "Query" which has such block:
RequestDispatcher dispatcher = request.getRequestDispatcher("/servlets/counter");
if (dispatcher != null) {
out.println("<br>Number of visits: ");
request.setAttribute(Counter.ATTRIBUTE, Query.class.getName());
dispatcher.include(request, response);
}
out.println("</body>");
It is designed to include another servlet's response into the current servlet. Then, I have the other servlet called "Counter" which has this line:
if (counterName == null) counterName = (String)request.getAttribute(ATTRIBUTE);
So, when I run "Query" there is no output from "Counter". You can review the full project from this repository Thank you in advance!