Hello, I have a server_server.jsp page with a form that when submitted goes to ServletInsertOrderService that inserts the form data into the database. I am trying to cause that when the data is entered, the browser returns to the server_server.jsp page and displays a alert of the javascript saying that the order was successfully inserted, my code is like this:
RequestDispatcher rd;
if( dao.cadastrarOS(os) ) {
rd = getServletContext().getRequestDispatcher("/paginas/ordem_servico.jsp");
rd.include(request, response);
out.print(
"<script type=\"text/javascript\">"
+"alert(\“Ordem inserida com sucesso!\”);"+
"</script>"
);
}
This code is doing exactly what I want, but this getRequestDispatcher () redirects to link , and I can no longer access any internal links on the page, since the links to other pages are obviously out of the Servlet context, so the glassfish returns the 404 error.
Instead of using getRequestDispatcher (), I have already tried to use the response.sendRedirect ("pages / server_server.jsp") , in that case I can enter the data and access the internal links, but the no javascript alert is displayed.
Anyone who has ever had this situation would have any suggestions?
Thank you all!