0

Проблема: подаю на сервлет запрос в запросе есть значение id, но на сервлете в doget не получается спарсить id и по id уже выбрать из базы определённый "ивент". .getEvent(Integer.parseInt(request.getParameter("eventId")));

     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    System.out.println("Enter doget");
    EventService eventService = new EventService();
    try {
        Event event = eventService.getEvent(Integer.parseInt(request.getParameter("eventId"))); //==========event = null;
//            System.out.println("Event:"+event.getName()+"ID:"+ event.getId());
            request.setAttribute("event", event);
            request.getRequestDispatcher("/editEvent.jsp").forward(request, response);
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

Перехожу я на данный сервлет с страницы index.jsp

<a href="${pageContext.request.contextPath}/editEvent?eventId=${event.id}">Edit</a>

по debug'у у меня event = null, по этому он ничего не может получить. Не могу понять. Буду благодарен за ответ

1 ответ 1

0

Проблема решена. Ясно, что выдавало NullFormatterException могу ошибиться, потому что у нас значение по запросу ГЕТ было получено, но так как в контроллере в getEvent концовка return null; То он нам и выбивал. Вот такая вот ошибка)

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.