wood burning stoves 2.0*
The moose likes Servlets and the fly likes Java and database data type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Java and database data type" Watch "Java and database data type" New topic
Author

Java and database data type

muntago Richard
Ranch Hand

Joined: Nov 13, 2010
Posts: 82
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: 61661
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
muntago Richard
Ranch Hand

Joined: Nov 13, 2010
Posts: 82
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: 61661
    
  67

muntago Richard wrote:i try putting it this way but it errored

How?
muntago Richard
Ranch Hand

Joined: Nov 13, 2010
Posts: 82
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: 515
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: 61661
    
  67

Continuing to keep us guessing as to what error you are getting will only delay any help further.
 
jQuery in Action, 2nd edition
 
subject: Java and database data type