File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Java and database data type Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply 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: 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
    
  13

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
    
  13

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
    
  13

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
 
Similar Threads
Java Servlet database transaction problem
how to retrieve value from autogenerated(oracle sequence) column in a servlet.
Thread Safty With StringBuilder
comparing Strings
Question about string immutable