aspose file tools*
The moose likes JSP and the fly likes How to make file uploader which can upload docx in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to make file uploader which can upload docx in jsp" Watch "How to make file uploader which can upload docx in jsp" New topic
Author

How to make file uploader which can upload docx in jsp

Pritam Chatterjee
Ranch Hand

Joined: Jul 31, 2011
Posts: 38

How to make file uploader which can upload docx in jsp


Pritam
Sumit Patil
Ranch Hand

Joined: May 25, 2009
Posts: 296

Are you using any framework in your project?


Thanks & Regards, Sumeet
SCJP 1.4, SCWCD 5, LinkedIn Profile
Pritam Chatterjee
Ranch Hand

Joined: Jul 31, 2011
Posts: 38

na any framework..i'm doing it in netbeans 7 using glasfish
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Apache Commons FileUpload is an excellent library to handle file uploads at the server side. It doesn't care about the file type being uploaded. Is that what you're asking about?
thor aniket
Ranch Hand

Joined: Jan 21, 2012
Posts: 40

does Apache commons lib require any FTP server of our own to upload the files?? or it's having its own method of uploading??
I wanted the same functionality but couldn't find any sample.



Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16233
    
  21

When you upload a file to a webserver, it doesn't require an FTP client or server. HTTP has its own protocols.

To make them work, you have to define a form with the multipart-mime attribute, which tells the server that there will be several different types of data coming in and that they will be encoded using the Multipart Internet Mail Extensions standard. You also have to include a file upload HTML control in the form. This control will present the client-side file selection dialog and define the characteristics of the uploaded file.

When the user has selected a file and clicked the "submit" button for that form, the HTTP client will prepare and transmit an HTTP data stream consisting of headers, form control values, and a MIME-encoded copy of the data read from the selected file. On the receiving side, the webapp will accept all of that and the file data will generally end up stored as a temporary file where it can be retrieved as an inputstream for the application logic to use however it wants. You will need something like the apache commons fileupload facility to help you unless you're really determined to re-invent the whole process yourself.

Note that what's actually uploaded isn't literally a "file", it's the data that came from a file, and the webapp never has to treat it as a file if it just wants to scan the incoming data and do something with it.

However, since it's a very common thing to take the uploaded data and put it into a server-side file (or a BLOB in a database), you can use plain old Java code to create a File and copy the incoming data into that file. What you name the server-side file and where you put it are up to you, except that you should never put that file in a directory that's part of a WAR or the webapp server.


Customer surveys are for companies who didn't pay proper attention to begin with.
thor aniket
Ranch Hand

Joined: Jan 21, 2012
Posts: 40

Hello Tim, I got what you've said. I even got a sample program of what you said just now using just HTTP with the form having Multipart MIME. First, I didn't know the workflow of it, but as you have explained it clearly, I got the whole procedure of file uploading with HTTP using Apache commons fileupload . Thank you so much.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to make file uploader which can upload docx in jsp