• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 20479
  • Last Modified:

How to upload an image in Java servlets

Hi,
I am new to Java Servlets programming.I am using Windows platform,Oracle HTTP Server(Servlet enabled).Can u please give me code to how to upload the images from a web Form to a server directory.I am trying to write the code using Servlets.
Thanks
Aayushdeep Garg
Web:
http://profile.iiita.ac.in/adgarg_02
0
aayush123
Asked:
aayush123
  • 5
  • 2
2 Solutions
 
Mayank SAssociate Director - Product EngineeringCommented:
I don't think that I understand your question properly. Does this help you?:

http://otn.oracle.com/sample_code/tech/java/servlets/htdocs/vsmfilters/fileupload.html
0
 
aayush123Author Commented:
I want the code thst will be on the server for uploading an image from my web form to the server.The code will be written in servlets for file uploading on the sever.It willbe executed on the server on pressing the submit button.
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Did the link that I posted, help? If not, try the code at this page:

http://forums.devshed.com/archive/t-122423
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
Mayank SAssociate Director - Product EngineeringCommented:
Add a doPost () method to it as well.
0
 
aayush123Author Commented:
Hi,
The code given at:
http://otn.oracle.com/sample_code/tech/java/servlets/htdocs/vsmfilters/fileupload.html
 
is not useful to me.
but I like something given at
http://forums.devshed.com/archive/t-122423
but it is not running and not understandable also.Please give another example.
Thanks.
Aayushdeep Garg
Web:
http://profile.iiita.ac.in/adgarg_02
0
 
Mayank SAssociate Director - Product EngineeringCommented:
What error is it giving? Any specific compilation errors/ runtime exceptions? If so, please post the code along with the error messages and tell at which line you are getting the error.
0
 
mjzalewskiCommented:
For a good snap-in component (open source), you might want to try

Apache Jakarta Commons FileUpload Component
http://jakarta.apache.org/commons/fileupload

I like this one because you can upload to memory or disk, multiple files at a time, and there is a forum where you can ask questions.

0
 
Mayank SAssociate Director - Product EngineeringCommented:
Please proceed with that recommendation.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now