This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
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

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
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!