How do I pick up the attachment from the client's machine, in a web-based email system?
Created May 4, 2012
Andrea Pompili You can do it using an HTML form, a Servlet and the class MultipartRequest of the O'Reilly package avaiable at http://www.servlets.com/resources/com.oreilly.servlet/.
In this zip file (named cos.zip) you can found all the information you need to upload a file using a browser and a servlet.
Remember that the file you upload is stored in the server filesystem, so remember to remove it after sending your E-mail.
I tried also another way that worked perfectly, but is more complicated.
I wrote three classes :
In this zip file (named cos.zip) you can found all the information you need to upload a file using a browser and a servlet.
Remember that the file you upload is stored in the server filesystem, so remember to remove it after sending your E-mail.
I tried also another way that worked perfectly, but is more complicated.
I wrote three classes :
- A mine DataSource for handling a stream of byte with a filename and a content type
- An ExtendedMultipartRequest class that extracts the parts from the stream of the Servlet (similar to the one provided by O'Reilly)
- A MultipartInputStream for reading the InputStream of the servlet line by line