| Author |
Java and database data type
|
muntago Richard
Ranch Hand
Joined: Nov 13, 2010
Posts: 75
|
|
Good day. I have worked with java swing but wants to migrate some parameters and variables to servlets.
In my swing i have this
Now how do i write this in servlet or jsp
i wrote it this way but its not working
varible str1 is representing amount which has integer datatype in the database. please correct me in jsp/servlet
thanks
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56177
|
|
Well, you would never write this in a JSP because it is not acceptable to put Java code in a JSP, so I'll move this to the Servlets forum.
Please explain exactly what "not working" means.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
muntago Richard
Ranch Hand
Joined: Nov 13, 2010
Posts: 75
|
|
below is a swing code
which means that am trying to get a form field from textfield2 hence
str1=textfield2.getText(); and the form filed am trying to get has interger datatype hence
int1=Integer.parseInt(str1);
In servlet, how do i write this, i try putting it this way but it errored
thanks
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56177
|
|
muntago Richard wrote:i try putting it this way but it errored
How?
|
 |
muntago Richard
Ranch Hand
Joined: Nov 13, 2010
Posts: 75
|
|
I think the problem is here
str1=textfield2.getText();
in servlet i entered this
str1=request.getParameter("str1");
|
 |
amit punekar
Ranch Hand
Joined: May 14, 2004
Posts: 488
|
|
Hello,
We do not know what exception you faced.
But make sure you are getting "str1" as a request parameter and it is not null.
If you pass any non-numeric value in this request parameter then you will get NumberFormatException too. To avoid this you should validate for the "str1" if its numeric.
Regards,
amit
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56177
|
|
|
Continuing to keep us guessing as to what error you are getting will only delay any help further.
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: Java and database data type
|
|
|