0
I’m trying to get Servlet to work as a controller I was following the booklet from Caelum but I can’t find the error
to Servlet
@WebServlet(urlPatterns = "/LoginInfo")
public class LoginInfo extends HttpServlet {
public LoginInfo(){
super();
}
@Override
protected void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException{
}
protected void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException{
String acao = request.getParameter("acao");
String usuario = request.getParameter("usuario");
String senha= request.getParameter("senha");
Login login = new Login();
login.setUsuario(usuario);
login.setSenha(senha);
RequestDispatcher rd = null;
if(acao.equals("Entrar")){
rd = request.getRequestDispatcher("/paginaInicial.jsp");
rd.forward(request, response);
}
}
and the mistake it makes
java.lang.Nullpointerexception br.com.Vitor.controlador.Logininfo.doPost(Logininfo.java:41) javax.servlet.http.HttpServlet.service(Httpservlet.java:648) javax.servlet.http.HttpServlet.service(Httpservlet.java:729) org.apache.Tomcat.websocket.server.WsFilter.doFilter(Wsfilter.java:52) org.netbeans.modules.web.monitor.server.Monitorfilter.doFilter(Monitorfilter.java:393)
This is the line that makes the comparison if it equals "Enter"