I have the following code and i want that the Asistir button disapear if the user is suscribed in one event, what should i write in servlet and jsp to make it work? thanks.
The jsp button
<a href="formularioAsiste.jsp?id=${ev.idEvento}" class="btn btn-default">
<span class="glyphicon glyphicon-check">Asistir</span>
</a>
The Servlet that show the table
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
GestionAsistentes gestionAsistentes = new GestionAsistentes();
GestionEventos gestionEventos = new GestionEventos();
Collection<Evento> listaEventos = gestionEventos.list();
Collection<Asiste> listaAsistentes = gestionAsistentes.list();
request.setAttribute("asistentes", listaAsistentes);
request.setAttribute("eventos", listaEventos);
request.getRequestDispatcher("tabla.jsp").forward(request, response);
// request.getRequestDispatcher("TablaEventosServlet").forward(request,
// response);
}
ListaAsistentes have the user that asist and the event related to that user, the code:
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
String strIdEvento = request.getParameter("evento");
Usuario asis = (Usuario) request.getSession().getAttribute("usuario");
GestionEventos gesEven = new GestionEventos();
Evento ev = gesEven.getEventoPorId(Integer.parseInt(strIdEvento));
String nombreEntidad = request.getParameter("nombreEntidad");
String nombreCuenta = request.getParameter("nombreCuenta");
String iban = request.getParameter("iban");
String numeroCuenta = request.getParameter("numeroCuenta");
Date fechaPago = new Date();
GestionAsistentes gestionAsistentes = new GestionAsistentes();
Asiste asistente = new Asiste(nombreEntidad, nombreCuenta, iban, numeroCuenta, fechaPago);
asistente.setPrimaryKey(new UsuarioEventoId(asis,ev));
gestionAsistentes.addAsistente(asistente);
request.setAttribute("asistentes", gestionAsistentes.list());
response.sendRedirect("TablaEventosServlet");
}