Before posting this question I cross referenced previous questions on this and other communities blog but my problem remains.
Problem
I am not able to redirect my servlet to a new jsp from the doPost() method in the servlet. I called the doPost method from the javascript file as shown below in the code snippets. The control comes to the doPost() method which I checked through System.out.println statements but it never dispatches to the helloWorld.jsp I am using eclipse/and Tomcat 9.0.
My Servlet code:
@WebServlet(
name = "OpenSourceMapCtrl",
description = "Open Source Map Main Controller",
urlPatterns = {"/callMasterDateHandler"}
)
public class MainAppCtrl extends HttpServlet{
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
RequestDispatcher dispatcher =request.getRequestDispatcher("/helloWorld.jsp");
dispatcher.forward(request, response);
} catch(Exception e){
e.printStackTrace();
}
}
}
$.post("callHelloWorldHandler", function(data) {
console.info('@#@ data = ',data);
});
The firebug console shows 200 Ok for the page "hello world.jsp". But the page does not render.