File upload Servlets/JSP example / How to send e-mails from Servlets by JavaMail API
Free source code example for file upload Servlets/JSP by multipart/form-data. Example for how to send e-mails from Servlets/JSP by JavaMail API at the scheduled time.
Another solution... file upload by e-mail :
The file upload by multipart/form-data works in most cases. However, a growing number of the WAP phones are shipped with the digital cameras, i.e. the users can take the pictures by their mobile phones and send them to their friends by the e-mails. And, by OOP Pop3Receiver API, you can take the advantage of this feature. It is the Java API for connecting to the POP3 servers through JavaMail API, and you can extract the file attachment from the received e-mail. Be ready for file upload from WAP phone!
First example of FormGenerator API
This is the first-step example of OOP FormGenerator API. This source code example consists of 2 Servlet:
The first one generates the empty CGI FORM.
The POST request from this CGI FORM will be sent to the second Servlet. The second Servlet verifies all the request parameters. If some request parameter is invalid, the second Servlet shows the same CGI FORM again. But, at this time, the CGI FORM includes the previous request parameters in it, as the default values. In addition, this CGI FORM indicates which input is invalid.
The POST request from this CGI FORM will be sent to this Servlet again.
When all the request parameters are verified, the second Servlet shows the HTML table including them.
Second example of FormGenerator API
This is the second example of OOP FormGenerator API.
In case of the JSP/JSTL based solution like Apache Struts or JavaServer Faces, the localized message should be written in the property resource file for the expected Locale.
In the framework design by OOP FormGenerator API, Localization (L10n) of Servlet can be very easy.
For each expected Locale (language preference), the localized messages can be written in the normal HTML.
So, there is not difficulty even in the 2 bytes characters such as Japanese Shift_JIS, Chinese BIG5 or GB2312.
But it should be 12-34-56-78-90 in France:
This means the different algorithm must be applied to the input validation for each Locale. It may sound somewhat difficult. But, don't worry! Because the acceptable data type can also be written in the XML, FormGenerator API makes the things very easy.
Free source code examples of file upload Servlet/JSP by multipart/form-data
They depend on OOP MimeParser, the Java API for file upload Servlet/JSP. This API parses the InputStream of multipart/form-data and saves the uploaded files under the specified directory. With this Java API, you can:
If the user tries to upload the larger files or the files of the invalid mime-types, this API throws the exception. In this case, your Servlet/JSP can catch the exception and show the appropriate message. Your Servlets/JSP has the full control over where to save the uploaded files.
How to send e-mail from Servlet / JSP with JavaMail API. You can upload files by multipart/form-data and attache them to the e-mail. You can send e-mails at the scheduled time. When you specify when the e-mail will be sent, the available TimeZones will be listed and you can select the favorite Time Zone among them. The e-mail is stored into the SQL table by the Object Serialization. Once the e-mail is queued, the back-ground Thread will select it at the scheduled time and send it.
Java and all Java-based trademarks and logos are trademarks or registered of Sun Microsystems, Inc. in the United States and other countries.
ALL CONTENTS COPYRIGHT 1997-2007, OOP-Research Corporation. All rights reserved.