Skip to content Skip to sidebar Skip to footer

Servlet, Jsp, Javabeans And Html Form

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 browe

Solution 1:

Check the generated HTML output (rightclick page in browser, choose View Source). Don't you miss something?

<inputtype="radio" name="SongInfo" value=The bodyguard>

Yes, the quotes (note the difference in highlighted color, bodyguard became an attribute).

So, fix it:

<input type="radio" name="SongInfo" value="${item.title}">

This way it'll be generated as follows:

<inputtype="radio" name="SongInfo" value="The bodyguard">

Simple fix, isn't it? :)


That said, your JDBC code is prone to resource leaks. You should close all the resources Connection, Statement and ResultSet in the finally block of the try block you've acquired them. For more hints see this article. Also the list doesn't necessarily need to be put in the session scope. Also the HTML is syntactically invalid, but that's maybe just a copypaste error, it would otherwise not have worked.

Further on, your HTML form is declared to use the request method of GET, but it is also declared to use encoding type of multipart/form-data. This makes no utter sense. Only use this enctype whenever you have an <input type="file"> and if this is the case, the request method ought to be POST.

Post a Comment for "Servlet, Jsp, Javabeans And Html Form"