• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

How to make file uploader which can upload docx in jsp  RSS feed

 
Ranch Hand
Posts: 38
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to make file uploader which can upload docx in jsp
 
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using any framework in your project?
 
Pritam Chatterjee
Ranch Hand
Posts: 38
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
na any framework..i'm doing it in netbeans 7 using glasfish
 
Saloon Keeper
Posts: 4743
117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 40
Hibernate jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 19725
92
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
thor aniket
Ranch Hand
Posts: 40
Hibernate jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!