aspose file tools*
The moose likes JSP and the fly likes Save data from JSP text box to database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Save data from JSP text box to database" Watch "Save data from JSP text box to database" New topic
Author

Save data from JSP text box to database

Mag Yeoh
Ranch Hand

Joined: Oct 08, 2006
Posts: 42
hi....i'm very new in JSP and Java...but now i handle a project that need to use this 2 Language....

the problem is that i need add the data that i keyin in the webapplication text box to my database....all the process i need to do in java...

in my webapplication only got 2 text box...one is Country Name and another one is Country Population....i want to save this 2 field to my database after i key in a value/data...

can any one who know this help me...really appreciate yr knowledge....Thanks..
Natasza Biecek
Greenhorn

Joined: Oct 26, 2006
Posts: 28
Hi,
also hello to all, it's my first post here...

You need two things to do that:
1. a html/jsp page to allow user to input data
2. a servlet to process incoming data

So, let's write dataInputPage.jsp


It is a very simple form having two edit-boxes named
'form_country_name' and 'form_country_population'.
This form posts user input to 'dataProcessingServlet' which
will be our backend...

Now, dataProcessingServlet.java


Servlet performes basic validation of incoming data
and when something is wrong - shows list of problems...
When input data looks more-or-less good it establishes connection
to database and tries to insert data.

Please, treat all of this as a kind of draft, many things
should be done better...

regards,
Natasza
[ October 26, 2006: Message edited by: Natasza Biecek ]
Mag Yeoh
Ranch Hand

Joined: Oct 08, 2006
Posts: 42
Thanks Natasza....this is my first time write a project using JSP...

oh...i forget to tell that, they dont want me to use servlet in my java file...need to use useBean/java....it is possible to do that???

Problem...
1. dont want use servlet in my java file
2. they need me to use "useBean"? It is possible to do that?
3. i using db4o database....i not using mySQL....
Mag Yeoh
Ranch Hand

Joined: Oct 08, 2006
Posts: 42
Really Thanks a lot....yr coding very good....
Mag Yeoh
Ranch Hand

Joined: Oct 08, 2006
Posts: 42
Thanks Natasza ....

when i run your coding i having this error....i using eclipse to run jsp and java....

error is ....below is the error i get when i run your coding...i scare that i having a setting problem....you know what happen to this error..it is my setting problem.....
type Status report

message /SampleProject/Forum/SimpleExample.dataProcessingServlet

description The requested resource (/SampleProject/Forum/SimpleExample.dataProcessingServlet) is not available.


--------------------------------------------------------------------------------

Apache Tomcat/5.5.17
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Mag Yeoh, all you need is a good tutorial or a book for JSP/Servlet beginners.
Mag Yeoh
Ranch Hand

Joined: Oct 08, 2006
Posts: 42
ok. Thanks your very much....Thanks for you help....i use your way idea to run in another way....

Haha....i copy right your idea....

anyway, thanks.....

Cheers....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Save data from JSP text box to database