Good evening colleagues,
Please, I need the help to understand what is going wrong,
I have the following form:
form action="CronogramaNegocio" method="get">
<div class="col-md-3 form-group">
<label>DEPARTAMENTO</label>
<select class="form-control" required name="departamento" >
<option selected disabled>Selecione</option>
<option value="QUALIDADE">QUALIDADE</option>
<option>LIVROS FISCAIS</option>
<option>-</option>
</select>
</div>
<div class="col-md-3 form-group">
<label>DATA</label>
<input type="date" class="form-control" name="hData"/>
</div>
<div class="col-md-3 form-group">
<label>Hora Inicial</label>
<input type="time" class="form-control" name="hInicio"/>
</div>
<div class="col-md-3 form-group">
<label>Hora Final</label>
<input type="time" class="form-control" name="hFim"/>
</div>
<div class="col-md-2 form-group">
<label>TIPO AUDITORIA</label>
<select class="form-control" required name="tipoAuditoria" >
<option selected disabled>Selecione</option>
<option value="1ªPARTE">1ª PARTE-</option>
<option>2ª PARTE</option>
<option>3ª PARTE</option>
</select>
</div>
<p style="float:right;">
<input type="submit" class="btn btn-verde" value="Salvar" onclick="salvar()" />
</p>
</form>
As you can see it calls a Servlet called BusinessCronogram
Passing parameters I think is correct since the result is:
http://localhost:8080/Qualidade/CronogramaNegocio?departamento=LIVROS+FISCAIS&hData=2018-11-06&hInicio=21%3A01&hFim=01%3A01&tipoAuditoria=1�PARTE&frm_length=10
Within the Servlet I perform operations to write to the database the data:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package controller;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.CronogramaAuditoria;
import model.DAO.CronogramaAuditoriaDAO;
/**
*
* @author Rafael H. Aguiar
*/
public class CronogramaNegocio extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
System.out.print("Entrou no metodo de salvar Cronograma");
String tipoAuditoria = request.getParameter("tipoAuditoria");
String data = request.getParameter("data");
String departamento = request.getParameter("departamento");
String hInicio = request.getParameter("hInicio");
String hFim = request.getParameter("hFim");
CronogramaAuditoriaDAO croDAO = new CronogramaAuditoriaDAO();
CronogramaAuditoria cro = new CronogramaAuditoria(tipoAuditoria, data, hInicio, hFim, departamento);
croDAO.create(cro);
System.out.print("Registro salvo com sucesso");
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP <code>POST</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
However, the following error is displayed:
HTTP Status 404 - /Qualidade/CronogramaNegocio
type Status report
message /Qualidade/CronogramaNegocio
description The requested resource is not available.
Apache Tomcat/7.0.56
Would anyone please kindly tell me why?