You can't call a servlet directly from a JSP. However, you can send a redirect. This will tell the browser that it should look for the resource in another location.
From JSP
<%
String destination ="/jsp/destination.jsp";
response.sendRedirect(response.encodeRedirectURL(destination));
%>
From Serlet
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String destination ="/jsp/destination.jsp";
response.sendRedirect(response.encodeRedirectURL(destination));
}
}
If your purpose is "logging" you should use a Filter. A Filter is like a lightweight servlet that doesn't generate its own content, instead it plugs into the request handling process and executes in addition to the normal page processing.
A strong recommendation is to use Servlet/JSP in a MVC pattern way. It seperates the application's data, user interface and control logic into three separate entities. The request is handled by a Servlet (the controller) which will initialize any JavaBeans (the model) required to fulfill the user's request. The Servlet (the controller) will then forward the request, which contains the JavaBeans (the model), to a JSP (the view) page which contains only HTML and JSTL syntax.