wood burning stoves 2.0*
The moose likes JSP and the fly likes Upload Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Upload" Watch "Upload" New topic
Author

Upload

vishal sodani
Ranch Hand

Joined: Aug 26, 2000
Posts: 127
Hi,
I have an HTML page,in which user fills two textboxes(name and biography details) and in third textbox gives the path of an image to be uploaded.How can I upload all the three information to webserver and then save it to a database using JSP
thanks
vishy
Roy Ben Ami
Ranch Hand

Joined: Jan 13, 2002
Posts: 732
you have many options.
you can write the whole database code in the same jsp page, or use a form to submit it to a servlet which will handle it or use a bean that will act as the link to the database.
in all options u get the parameters in the textfields using the
request.getParameter(name of field);
then u can whatever u wish with it.
vishal sodani
Ranch Hand

Joined: Aug 26, 2000
Posts: 127
but what about the image,whose path is given in the textbox?what will I have to write to upload the image from the local disk?
thanks
Naveen Sydney
Ranch Hand

Joined: Jan 21, 2002
Posts: 30
Originally posted by vishal sodani:
but what about the image,whose path is given in the textbox?what will I have to write to upload the image from the local disk?
thanks

when u use the <input type='file'> the actual file gets submitted not just the path in the textbox. Do refer to multipart mimetypes(O'Reiley has one that u can download for free).
Also after you have uploaded the image from the clients computer to your webserver u need to save it in the database. if u are using oracle there are specific datatypes u can declare to store images. But my suggestion is to write the image into the webservers hard drive and store the path in the database.
regards
syd
vishal sodani
Ranch Hand

Joined: Aug 26, 2000
Posts: 127
Hi,
Can anyone help me with an example with code how to parse a multipart/form-data.In my case,I have two textbox and an image to upload.
thanks
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
You have to use one of the packages that are available out there. It's not that straight forward. O'reilley has one out there, as mentioned previously. You can search this forum or www.google.com for some links.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Upload
 
Similar Threads
How to browse & upload the image using struts2?
File OutPut
name of the submittion jar file
Uploads rights, how long
Sun's Free Proficiency Assessment System