Greetings,
Within my jsp I have HTML code (see below) which accepts input, one of these fields sequence unlike the others is an Integer and within the HTML FORM the INPUT TYPE is set to "int".
<FORM ACTION="wk465682AddFAQ.jsp" METHOD="POST">
Id: <INPUT TYPE=TEXT NAME=Id><BR><BR>
Category: <INPUT TYPE=TEXT NAME=category><BR><BR>
Question<BR><TEXTAREA NAME=question COLS=100 ROWS=2></TEXTAREA><BR><BR>
Answer<BR><TEXTAREA NAME=answer COLS=100 ROWS=4></TEXTAREA><BR><BR>
Sequence: <INPUT TYPE="int" NAME=sequence><BR><BR>
<INPUT TYPE=Submit VALUE="Add to Database">
</FORM>
These values are then retrieved in the same jsp file using the code below and inserted into the table (sequence field is Number format in MS acess table):-
Enumeration parameters = request.getParameterNames();
if(parameters.hasMoreElements()) {
String IdParam = request.getParameter("Id");
String categoryParam = request.getParameter("category");
String questionParam = request.getParameter("question");
String answerParam = request.getParameter("answer");
Integer sequenceParam = request.getParameter("sequence");
statement.executeUpdate("INSERT INTO FAQ (\"Id\",\"category\", \"question\", \"answer\", \"sequence\", \"UserId\", \"created\") VALUES ('"+IdParam+"','"+categoryParam+"','"+questionParam+"','"+answerParam+"', '"+sequence+"', '"+ session.getAttribute("theName")+"', '"+dateString+"') ");
}
ResultSet columns = statement.executeQuery("SELECT * FROM FAQ");
while(columns.next()) {
String Id = columns.getString("Id");
String category = columns.getString("category");
String question = columns.getString("question");
String answer = columns.getString("answer");
String userId = columns.getString("userId");
String created = columns.getString("created");
Integer sequence = columns.getInt("sequence");
The jsp falls over with error regarding sequence as It cant convert between String to Integer and Int to Integer.
I've been looking at examples, but obviously I arent declaring the sequence value as an Integer properly.
Any advice would be appreciated
Cheers Rob