/** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */
 protected void doGet(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   Gson gson = new Gson();
   VeiculoDAO veiculoDAO = new VeiculoDAO();
   String jsonValue = gson.toJson(veiculoDAO.selectByMarca(""));
   response.setContentType("application/json");
   response.setCharacterEncoding("UTF-8");
   response.getWriter().write(jsonValue);
 }
コード例 #2
0
 /** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */
 protected void doGet(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   ClienteDAO clienteDAO = new ClienteDAO();
   VeiculoDAO veiculoDAO = new VeiculoDAO();
   List<Cliente> resultCliente = null;
   resultCliente = clienteDAO.selectByName("");
   ArrayList<String> cidades = veiculoDAO.selectCities();
   List<Veiculo> veiculos = veiculoDAO.selectByUf("");
   request.setAttribute("resultCliente", resultCliente);
   request.setAttribute("cidades", cidades);
   request.setAttribute("veiculos", veiculos);
   RequestDispatcher view = request.getRequestDispatcher("locacao.jsp");
   view.forward(request, response);
 }