I'm a beginner in Java EE, I am trying to pass a checkbox's "checked" from a JSO to another, here is how it works :
The "From" JSP :
I am forwarding a request to a BookEdit.java servlet through an "Edit" link :
<td><a href="./BookEdit?author=<%= bookData.getBookList().get(i).getAuthor() %>&title=<%= bookData.getBookList().get(i).getTitle() %>&availabe=<%= bookData.getBookList().get(i).isAvailable() %>">Edit</a></td>
Which generates links like : http://localhost:8080/LibraryWeb/BookEdit?author=H.P.%20Lovecraft&title=Call%20of%20Cthulhu&availabe=true
The servlet simply forwards the request to the second JSP through its doGet()
The "To" JSP :
<%@ page pageEncoding="UTF-8" %>
<%@ page language="java" %>
<%@ page contentType="text/html; charset=utf-8" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Gestion de bibliothèque - Edition de livres</title>
</head>
<body>
<h1 align="center">Gestionnaire de bibliothèque</h1>
<hr width="50%">
<h3 align="center">Edition de livre</h3>
<form method=post action=./BookEdit>
<table align=center border=1px>
<tr>
<td>Author : </td>
<td><input type=text name="author" size=20 maxlength=200 value="<%= request.getParameter("author") %>"></td>
</tr>
<tr>
<td>Title : </td>
<td><input type=text name="title" size=20 maxlength=200 value="<%= request.getParameter("title") %>"></td>
</tr>
<tr>
<td>Available : </td>
<td>
<% if (request.getParameter("available") == "true") { %>
<input name="available" value="true" type="checkbox" checked="checked">
<% }
else { %>
<input name="available" value="false" type="checkbox">
<% } %>
</td>
</tr>
</table>
</form>
</body>
The problem is, the checkbox on the second JSP is always unchecked, even if the "available" parameter has a "true" value. So what am I doing wrong ?
Thank you.
Found the solution : I simply replaced the forwarding using a link with a form. But I would still like to know why the link approach didn't work.