Fui tentar usar uma página dinamica para imprimir a empresa adicionada, mas apresenta um erro:
novaEmpresa.jsp
<html>
<body>
Empresa adicionada : ${empresa}
</body>
</html>
novaEmpresa.java
package web;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import br.com.alura.gerenciador.Empresa;
import br.com.alura.gerenciador.dao.EmpresaDAO;
@WebServlet(urlPatterns = "/novaEmpresa")
public class NovaEmpresa extends HttpServlet{
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String nome = req.getParameter("nome");
Empresa empresa = new Empresa(nome);
new EmpresaDAO().adiciona(empresa);
req.setAttribute("empresa", empresa);
RequestDispatcher dispatcher = req.getRequestDispatcher("/WEB-INF/paginas/novaEmpresa.jsp");
dispatcher.forward(req, resp);
}
}
Erro
HTTP Status 500 - java.lang.IllegalStateException: No output folder
type Exception report
message java.lang.IllegalStateException: No output folder
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: java.lang.IllegalStateException: No output folder
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:585)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:391)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:335)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
web.NovaEmpresa.doPost(NovaEmpresa.java:29)
javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
web.FiltroDeAuditoria.doFilter(FiltroDeAuditoria.java:49)
root cause
java.lang.IllegalStateException: No output folder
org.apache.jasper.JspCompilationContext.createOutputDir(JspCompilationContext.java:656)
org.apache.jasper.JspCompilationContext.getOutputDir(JspCompilationContext.java:193)
org.apache.jasper.JspCompilationContext.getClassFileName(JspCompilationContext.java:504)
org.apache.jasper.compiler.Compiler.isOutDated(Compiler.java:444)
org.apache.jasper.compiler.Compiler.isOutDated(Compiler.java:408)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:557)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:335)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
web.NovaEmpresa.doPost(NovaEmpresa.java:29)
javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
web.FiltroDeAuditoria.doFilter(FiltroDeAuditoria.java:49)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.12 logs.
Apache Tomcat/8.0.12