package com.arrgsocal.servlets.crud;
import java.io.IOException;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.arrgsocal.entities.Todo;
import com.arrgsocal.managers.TodoManager;
/**
* Servlet implementation class GetTodo
*/
@WebServlet("/GetTodo")
public class GetTodo extends HttpServlet
{
private static final long serialVersionUID = 1L;
@EJB
TodoManager todoManager;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
int id = Integer.parseInt(request.getParameter("id"));
Todo t = todoManager.getTodo(id);
if (t == null)
{
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Entity not found");
}
request.setAttribute("todo", t);
getServletContext().getRequestDispatcher("/WEB-INF/ToDo.jsp").forward(request, response);
return;
}
}