Servlet, JSP, JavaBeans and HTML form

Posted by dedalo on Stack Overflow See other posts from Stack Overflow or by dedalo
Published on 2010-03-04T22:46:41Z Indexed on 2010/03/08 12:21 UTC
Read the original article Hit count: 437

Filed under:
|
|
|
|

Hi, I'm working on a servlet that makes a connection to a database gets the information of one of the tables ans sends this information to a jsp file. This file will print on the brower the information table, adding radio buttons that allows us to choose one of the rows.

The servlet looks like this:

List<InfoBean> items = new ArrayList<InfoBean>();
if (!conexion.isClosed()){
  Statement st = (Statement) conexion.createStatement();          
  ResultSet rs = st.executeQuery("select * from lista_audio" );
  while (rs.next())
  {items.add(getRow(rs));}
  conexion.close();}
req.getSession().setAttribute("items", items);

In the JSP file I can print a table with the information, adding radio buttons that the user will use to choose 1 row and send the selected info to a servlet using a form I can add:

< form action="administ" method=get enctype=multipart/form-data>    
< table>
 < table border=\"1\">< tr>< th>Title< /th>< th>Author< /th>< th>Album< /th>< /tr>
 < c:forEach items="${items}" var="item">
 < tr>< td><input type="radio" name="SongInfo" value=${item.title}>
 < td>${item.title}< /td>
 < td>${item.author}< /td>
 < td>${item.album}< /td>< /tr>
 < /c:forEach>
< /table>

In the field 'value' I should be able to send to the servlet the information stored in ${item.title}. When I set value = ${item.title} and title is, for example "The bodyguard", in the servlet the information I can retrieve is just "The". It looks like it sends the characters located before the first white space of the string. How could I get the whole string?

Thanks

© Stack Overflow or respective owner

Related posts about java

Related posts about servlets