Error 500 jsp Help

0

votar en contra
accept
 <label required>Departamentos</label>
  <select class="form-control" onchange="buscarProvincia(this);" id="nIdeDptoNac">                  
           <option value="${cmb.nIdeCompendio}">--Seleccione--</option>                            
           <c:forEach var="cmb" items="${combo}">
           <option value="${cmb.nIdeCompendio}">${cmb.vNomCorto}</option>
           </c:forEach>
                            
 </select>

I'm trying to fill a combobox (select) in a jsp with servlet and jstl but it sends me error to a line of code, I check it and everything is fine, if you can help me !!! ... I'll leave it to you I have so far The error sends me on line 34 of the servlet (null pointer) the mysql select returns data

public class ComboDAOimpl {
Connection conn = null;
PreparedStatement pstm = null;
ResultSet rs = null;
CatDetCompendioDTO catDetCompendioDTO =null;

public List<CatDetCompendioDTO> llenarCombos(String sql){
    List<CatDetCompendioDTO> listaCombo = new ArrayList<CatDetCompendioDTO>();
    try {
        conn = Conexion.getConexion();
        pstm = conn.prepareStatement(sql);
        rs = pstm.executeQuery();
        while(rs.next()) {
            catDetCompendioDTO = new CatDetCompendioDTO();
            catDetCompendioDTO.setnIdeDetalle(rs.getInt("nIdeDetalle"));
            catDetCompendioDTO.setvNomCorto(rs.getString("vNomCorto"));
            catDetCompendioDTO.setvNomLargo(rs.getString("vNomLargo"));
            listaCombo.add(catDetCompendioDTO);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return listaCombo;
}

----------------------------------------------------------

@WebServlet ("/ comboController") public class comboController extends HttpServlet {     private static final long serialVersionUID = 1L;

public comboController() {
    super();
    // TODO Auto-generated constructor stub
}
ComboService comboService;

protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    req.setAttribute("combo", comboService.listarDepartamentosService());
    req.getRequestDispatcher("listaPeliculas.jsp").forward(req, res);
}

public class ComboServiceImpl implements ComboService {

 private ComboDAO comboDepartamento;

public List<CatDetCompendioDTO> listarDepartamentosService() {

    List<CatDetCompendioDTO> listaDepartamento = new ArrayList<CatDetCompendioDTO>();
    StringBuffer sql = new StringBuffer();
    sql.append("select nIdeDetalle,vNomCorto,vNomLargo from catdetcompendio where nidecompendio=9  order by vNomCorto");
    try {
        listaDepartamento   = comboDepartamento.llenarCombos(sql.toString());
    }catch (Exception e) {
        e.printStackTrace();
    }
    return listaDepartamento;
}

'

    
asked by Jorge Cabrera 31.05.2018 в 18:14
source

1 answer

0

In the controller you are limiting yourself to declaring an attribute of type ComboService but you are not instantiating it anywhere nor are you delegating any additional framework to be injected, which is why that NullPointer you speak of occurs.

If you are actually injecting or initializing it elsewhere, attach that code. Otherwise, the solution is as simple as:

ComboService comboService = new ComboServiceImpl();

Although seeing the code, probably the same thing will happen to you later but with the attribute comboDepartamento that you have in the service.

    
answered by 31.05.2018 / 22:28
source