Greetings,
Within my jsp I have HTML code (see below) which accepts input, one of these fields sequence unlike the others is an Integer. - <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 in a Number in MS acess):- - 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
2 3864 Dököll 2,364
Recognized Expert Top Contributor
You should probably use an Auto-Generated ID in your back-end, if which case you would not need : -
-
String Id = columns.getString("Id");
-
-
In which case, it should really be: -
-
int Id = columns.getInt("Id");
-
-
but again, only if necessary would you need to insert id values in code. maintain your back-end to accept an auto number when data are added, then you can retrieve using getInt...
JosAH 11,448
Recognized Expert MVP @robtyketto
Here are the valid type specifications for an input field: HTML input type Attribute
As you can see there is no such thing as an 'int' type; also note that this has nothing to do with auto generated values; forget about that; that reply was totally incorrect.
kind regards,
Jos
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: RobertMaas |
last post by:
After many years of using LISP, I'm taking a class in Java and finding
the two roughly comparable in some ways and very different in other
ways. Each has a decent size library of useful utilities as a standard
portable part of the core language, the LISP package, and the java.lang
package, respectively. Both have big integers, although only LISP has
rationals as far as I can tell. Because CL supports keyword arguments,
it has a wider range...
|
by: Robert Baer |
last post by:
I used Google and found some references for integer in Java.
But "int" not only does not work, it also prevents reading X and Y
coordinates of the mouse.
What i would like to do:
1) Get X and Y mouse coordinates into a variable that i can do real math on.
So far, i can do math on the values "read" and that result goes into
a "variable" that is useful *only* for display.
If i try "int" in that math, the values are then zero for everything...
|
by: wellstone9912 |
last post by:
Java programmers seem to always be whining about how confusing and
overly complex C++ appears to them. I would like to introduce an
explanation for this. Is it possible that Java programmers simply
aren't smart enough to understand C++?
This is not merely a whimsical hypothesis. Given my experience with
Java programmers --- the code they write and the conversations they
have --- Occam's Razor points to this explanation. For example,...
|
by: Jobs |
last post by:
Download the JAVA , .NET and SQL Server interview with answers
Download the JAVA , .NET and SQL Server interview sheet and rate
yourself. This will help you judge yourself are you really worth of
attending interviews. If you own a company best way to judge if the
candidate is worth of it.
http://www.questpond.com/InterviewRatingSheet.zip
|
by: Xah Lee |
last post by:
On Java's Interface
Xah Lee, 20050223
In Java the language, there's this a keyword “interfaceâ€.
In a functional language, a function can be specified by its name and
parameter specs. For example:
f(3)
f(3, )
| |
by: judge82 |
last post by:
please I am learning how to use servlet. here is my code
package TestWebApp;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class RegLoginServlet extends HttpServlet {
|
by: gypsyman58 |
last post by:
First I need to create 2 classes. The first will contain an ID number and an array of 5 course titles. I also have to create a get and a set method for populating the ID. I also must create a method to get a course. It does this by taking an integer and returning the course to that position (0 through 4). Then I must create a set method that sets the value of one of the courses by taking two arguements a name and an integer and returning the...
|
by: aarklon |
last post by:
Hi all,
See:- http://www.cs.princeton.edu/introcs/faq/c2java.html
for C vs Java in number crunching
http://husnusensoy.blogspot.com/2006/06/c-vs-java-in-number-crunching.html
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |