OOP-ResearchMake It Simpler by Object Oriented Programming

File upload Servlet by multipart/form-data / Free source code example for how to upload files by Servlet

File upload Servlets/JSP by multipart/form-data. Free source code example for how to upload files by Servlets/JSP. You can restrict the file size and the width/height of the image file to be uploaded. Servlet can save the uploaded files under the specified directory. You can get the binary contents and the Content-Type of the uploaded files.

This page lists the free source code examples and Java APIs related with HTTP POST request of multipart/form-data. For example, you can easily create Photo Album Servlets/JSP, to which you can upload the image files by multipart/form-data.

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!


PRODUCT: : Product by OOP-Research
DOC: : Documentation written by OOP-Research
PATCH: : Patch for the other vendor's system


DOC:Free source code examples of file upload Servlet/JSP by multipart/form-data

These examples will show you how to upload the files by Servlet / JSP through 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:

  • Restrict the size of the file to be uploaded
  • Restrict the mime-types (Content-Type) of the file to be uploaded
  • Restrict the width/height of the image file (JPEG, GIF or PNG)
  • Specify where to save the uploaded file

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.
With the easy programming interface of this API, a few lines of code will be enough for your file upload Servlet/JSP. Please download these source code examples and try them.



Go Site Map Read More

DOC:Source code example for how to send e-mail from Servlet with JavaMail API

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.



Go Site Map Read More

PRODUCT:OOP MimeParser

This Java API parses InputStream of HTTP POST request with multipart/form-data encode. By this Java API, only the single method call is enough for your file upload Servlets or JSP.

The uploaded file can be saved on the file system. Your Servlets/JSP has the full control over where to save the uploaded files. Or if you don't want to save the uploaded files, your Servlets/JSP can get the binary contents, the file name and the Content-Type of the uploaded files.

You can restrict the size of file to be uploaded. You can also restrict the mime-types (Content-Type) of the files to be uploaded. As for the image file (JPEG, GIF or PNG), you can set the maximum width/height. When the user tries to upload the larger files or the files of the invalid mime-types, this API will throw the exception, i.e. your Servlets/JSP has a chance to catch the exception and show the appropriate message.

Optionally, this Java API can check if the binary contents of the uploaded file are really the PNG, JPEG, GIF or PDF. If the binary contents do not match with the expected pattern of PNG, JPEG, GIF or PDF, this Java API throws the exception. By this way, your JSP/Servlet can prevent the fake file being uploaded.

In addition, your Servlets/JSP on Apache Tomcat can specify the charset used for parsing the text parameters in HTTP POST request with multipart/form-data encoding. By this way, your Servlets/JSP on Apache Tomcat can parse the multipart/form-data with any charset, even if it is 2 bytes characters such as Japanese Shift_JIS, Chinese BIG5, Chinese GB2312 or Russian KOI8-R.



Go Site Map Read More

PRODUCT:OOP RequestStore

This Java API stores the HTTP request parameters into the SQL table through JDBC. The unique ID is issued for each request, and another JSP / Servlet can use it to get the parameter values later.
Within the SQL table, the parameter values are stored in the form of URL-encoded String. Regardless of the configuration of the SQL database, the request parameters in the various charsets (including the 2 byte character such as Japanese Shift_JIS, Chinese BIG5, Chinese GB2312 or Russian KOI8-R) can be stored into the single database. This strategy also eliminates the unnecessary byte-to-String conversion.

With its easy programming interface, a few lines of code are enough for your interactive web applications and WAP services on Apache Tomcat.



Go Site Map Read More

PRODUCT:OOP JpegScaler

Java API for scaling JPEG image by Java Advanced Imaging API (JAI). The width/hight of the JPEG image will be reduced to fit within the specified rectangle. The ratio of width/height of the original JPEG image will be left unchanged. This Java API is useful to show the large JPEG image on the small screen of the WAP phone. For example, your Servlet can send the binary contents of the scaled JPEG image to the WAP device.

With its easy programming interface, a few lines of code are enough for your interactive web applications and WAP services on Apache Tomcat.



Go Site Map Read More


Caution!
All the APIs for Servlet/JSP introduced by this web site are now included in Bento framework:
  • Simpler than JSTL or Apache Struts
  • MVC framework by HTML
  • Input validation from CGI FORM
  • Easy user authentication
  • Easy localization (L10n)
To download the APIs and source code examples, please visit the web site of Bento framework.


JBuilder 2007


General Information

For Java Development

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.