OOP-ResearchMake It Simpler by Object Oriented Programming

Java API for JSP/Servlet programming : Java Swing GUI builder by XML

File upload JSP/Servlet example. multipart/form-data. CGI FORM input validation. JDBC/JavaMail. Java Swing GUI builder by XML.

By the Thread Safe Java API from OOP-Research, a few lines of codes are enough for your file upload JSP/Servlet to parse multipart/form-data. Your JSP/Servlet can use JDBC PreparedStatement and JavaMail API in a Thread Safe way, and can send e-mails at the scheduled time. And the input validation from the CGI FORM can be done by the single method call. The code fragments for HTML, XHTML, HDML or WML (WAP phones) can be written in XML. Simpler than the JSP/JSTL based solution such as Apache Struts or JavaServer Faces. Please download the free source code example.

Java Swing GUI builder (XML editor) by OOP-Research writes the nested structure of Swing GUI into the XML. By this GUI tool, you can specify which LayoutManager (such as GridLayout, BoxLayout or BorderLayout) will be used on JPanel. And any JComponents (such as JButton, JCombobox, JTextField, JTextArea, JTextPane or JTable) can be placed anywhere you like.

All the Java API and Swing GUI builder by OOP-Research are L10n (Localization) ready. Within your JSP/Servlet or Java Swing GUI, you can use any charset, including Japanese Shift_JIS, Chinese BIG5, Chinese GB2312 or Russian KOI8-R.

[ Site Map... ]

Spot Light

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


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!



Go Site Map Read More


Do you need BufferedImage?

When the image file is uploaded to your Servlet, its binary contents will be available in JPEG, PNG or GIF format. To manipulate the uploaded image file, those binary contents should be converted to a BufferedImage object. After your Servlet finishes to work on a BufferedImage object, it should be serialized back into the binary contents in JPEG, PNG, GIF or WBMP format to be send back to the web browser or to be stored into the SQL table. ImageUtil implements methods for converting the binary contents in typical image formats to/from a BufferedImage object.



Go Site Map Read More


DOC:Source code example of File Upload JSP/Servlet by multipart/form-data

This example source code consists of only one JSP and its helper classes. It is the simplest example in the world for how to upload the files by Servlet/JSP through multipart/form-data!

The main subjects of this example are:

  • How to set the maximum size of the file to be uploaded
  • How to restrict the mime-type (Content-Type) of the file to be uploaded. For example, if you'd like to allow the users to upload the files only of image/gif, image/jpeg or image/pjpeg, how can you do it?
  • How to check the binary contents of the uploaded file. For example, to prevent the fake file being uploaded, you may want to check if the uploaded file is really the PNG, JPEG, GIF or PDF. How can you do it?
  • How to set the maximum width/height of the image files (JPEG, GIF or PNG)

OOP MimeParser is the Java API for File upload Servlet/JSP. With the easy programming interface of this API, a few lines of code will be enough for your file upload Servlet/JSP. This API parses the multipart/form-data for the file upload request from the CGI FORM. You can specify the maximum size of the file to be uploaded. If the larger file is uploaded, this API throws the exception. In this case, your Servlet/JSP can catch the exception and show the appropriate message.
Moreover, you can restrict the mime-type (Content-Type) of the file to be uploaded. If the user tries to upload the file of other mime-type (Content-Type), this API throws the exception and your Servlet/JSP has a chance to catch the exception.
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, this Java API throws the exception. By this way, your Servlet/JSP can prevent the fake file being uploaded.
As for the image files (JPEG, GIF or PNG), your Servlet/JSP can restrict their width/height. If the user tries to upload the image file with the larger width/height, this Java API will throw the exception. And your Servlet/JSP can catch the exception and show the error message to the user.
In this Java API, you can write:

  • The maximum file size to be uploaded
  • The list of the acceptable mime-types (Content-Types)
  • The maximum width/height of the image file

in the property files. So, you can change the maximum file size and width/height, and can add/delete the acceptable mime-types (Content-Types) without updating the source code of your JSP/Servlet!



Go Site Map Read More


Articles and Java API

Java Swing GUI builder by XML

Java Swing GUI builder by XML. Free Source code examples for LayoutManager of Java Swing GUI. How to use JToolBar with BorderLayout. How to align JComponents by GridLayout and BoxLayout.
This page lists the Java Swing GUI builder and free source code examples for Java Swing GUI.

File upload Servlet/JSP by multipart/form-data

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 mime-types. 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.

How to send e-mails from Servlet/JSP by JavaMail API

Example for how to send e-mails from Servlets/JSP by JavaMail API. Servlets/JSP can send e-mails at the scheduled time. By multipart/form-data, you can upload files by Servlet and attache them to e-mails. The e-mails will be queued into SQL table through Object Serialization. The users can specify when the Servlets/JSP will send e-mails. The available TimeZones can be listed and the users can select the favorite TimeZone. At the scheduled time, the back-ground Thread will select e-mails and send them to the SMPT server.
This page lists the free source code examples and the Java APIs related with JavaMail API.

Free Source code example for Servlet/JSP

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.
This page lists the free source code examples for Servlets/JSP programming.

JDBC PreparedStatement on Servlet/JSP

To make JSP/Servlets on Apache Tomcat really Thread Safe, JDBC PreparedStatement must be ready for unlimited concurrent access. The pooling mechanism of JDBC PreparedStatement makes it possible. Session tracking without Cookie. User authentication mechanism without Realm.
This page lists the Java API for JDBC PreparedStatement on Servlet/JSP.

Servlet by HTML

HtmlToXml is the HTML-to-XML conversion tool with the Java Swing GUI. This conversion tool reads the normal HTML (or any mark-up languages such as XHTML, WML or HDML) and generates the XML. While in the conversion, you can specify the acceptable data types for the request parameters from the CGI FORM. These information can be used for the input validation from the CGI FORM.
This template framework makes the localization (L10n) easier than ever. Unlike the JSP/JSTL based-solutions (such as Apache Struts and JavaServer Faces), the web designers (or page authors) need not learn a bit of custom tag libraries. In this framework, what you need is to write the normal HTML for each expected Locale along with the localized messages. There is not difficulty even in the 2 bytes characters such as Japanese Shift_JIS, Chinese BIG5 or GB2312.
This page lists the Java API and examples by HtmlToXml.

Servlet/JSP with Japanese Shift_JIS, Chinese BIG5, GB2312

i18n (Internationalization) for Servlets/JSP on Apache Tomcat. HTTP request with 2 bytes characters, such as Japanese Shift_JIS, Chinese BIG5, Chinese GB2312 or Russian KOI8-R. HTTP response for Locale.
This page lists the Java API, patch and article related with Internationalization (i18n).

For JCE, RSA, Digital Signature

Java API for JCE, RSA and digital signature. A pair of RSA public key and private key can be generated on demand. Any Java objects can be encrypted and decrypted along with the digital signature.

How to for Apache Jakarta Tomcat

How to for Apache Tomcat. Installation and configuration of Jakarta Tomcat. Patches for Apache Tomcat.
This page lists the articles and tutorials for Apache Tomcat.

How to for JOnAS EJB server, Enhydra, MySQL

Solutions for JOnAS EJB server and MySQL. You can store 2 bytes characters, such as Japanese Shift_JIS, Chinese BIG5 or Chinese GB2312 into MySQL SQL database through JDBC PreparedStatement.

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.