• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java and database data type

 
muntago Richard
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
muntago Richard
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
muntago Richard wrote:i try putting it this way but it errored

How?
 
muntago Richard
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the problem is here
str1=textfield2.getText();

in servlet i entered this
str1=request.getParameter("str1");
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Continuing to keep us guessing as to what error you are getting will only delay any help further.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic