File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes File Uploading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "File Uploading" Watch "File Uploading" New topic

File Uploading

Maryam Nouhnejad
Ranch Hand

Joined: Oct 04, 2006
Posts: 39
Hello everyone,

I'm writing a web photo gallery project & I should use file uploading in order to upload the photos somewhere in the server-side.
But I'm not sure exactly how I should do this. So far I have created a jsp file (SelectFile.jsp) & written this peice of code in that :

<form action=http://localhost:8200/FileUploading/Upload.jsp enctype="multipart/form-data" method="post">
<input type=file name=file_name>
<input type=submit value=upload>

In Upload.jsp I make a bean object using the class below ( and call its method.

Here is that method :

public void doUpload(HttpServletRequest request) throws IOException

ImageWriter printW = new ImageWriter(new BufferedImage(new FileWriter("image")));

ServletInputStream in = request.getInputStream();

int i =;


printW.print( (char) i);

i =;



thanks in advance,

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Have a look at this entry in our servets faq.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: File Uploading
It's not a secret anymore!