I have a problem. I can't receive a value for GET
in the Servlet
, I don't know why. Here the JSP code:
<html>
<%
List<String> listaDeCategorias = (List<String>) request.getAttribute("listaDeCategorias");
String busquedaCategoria = (String)request.getAttribute("busquedaCategoria");
for(String categoria : listaDeCategorias){
if(categoria.equals( busquedaCategoria )){
%>
<option value="<%=categoria%>" selected><%=categoria%></option>
<%} else {%>
<option value="<%=categoria%>"><%=categoria%></option>
<%}}%>
</select>
<input type="submit" value="Filtrar">
</form>
<br>
<%
List<Libro> listaDeLibros = (List<Libro>) request.getAttribute("listaDeLibros");
for(Libro libro : listaDeLibros){
%>
<%=libro.getIsbn()%>
<%=libro.getTitulo()%>
<%=libro.getCategoria()%>
<a href="BorrarController?isbn = <%=libro.getIsbn()%>" >Borrar</a>
<a href="EditarLibroController?isbn = <%=libro.getIsbn()%>">Editar</a>
<br>
<%}%>
<a href="index.jsp">Registrar otro libro</a>
in the label part
<a href="BorrarController?isbn = <%=libro.getIsbn()%>" >Borrar</a>
I want to send the isbn code of the book by url
al Servlet
. The link takes me to Servlet
, but Servlet
it does not read the data sent by url
. Code of Servlet
:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String isbn = request.getParameter("isbn");
Libro libro = new Libro();
libro.borrar(isbn);
response.sendRedirect("MostrarLibrosController");
}
}
I appreciate your input.
The problem is that they are forming URLs with spaces and that by default adds a %20% to the url and the parameter you want will never arrive.
Change your hrefs to these:
And that the name of the serlvlet is the same that you previously configured in the xml: