File upload Servlet by multipart/form-data, JavaMail API, Java Swing GUI, Apache Tomcat, JOnAS EJB, MySQL
Free source code example for file upload Servlet/JSP by multipart/form-data, JavaMail API, Java Swing GUI and XML. How to for Apache Tomcat, JOnAS EJB and MySQL.
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.
The typical Java Swing GUI has a series of JTextField along with their corresponding JLabel. By GridLayout and BoxLayout, you can place these pairs of JTextField and JLabel aligned gracefully. This example shows how to use GridLayout and BoxLayout.
Java Swing example for JApplet by Java Swing GUI Tool. Floatable JToolBar can be placed on BorderLayout with Action. The JMenuItems on JMenu are enabled/disabled along with JButtons on JToolBar.
By Java API from OOP-Research, the development of web applications or WAP services will be easier. A few lines of codes are enough for your JSP or Servlet programming to use XML, JDBC or JavaMail API. Your JSP/Servlet can accept HTTP POST requests with multipart/form-data encode for file upload. And HTTP POST request parameters with Japanese Shift_JIS, Chinese BIG5, Chinese GB2312 or Russian KOI8-R can be decoded easily. Or, the unique session ID can be generated per each user login and a series of HTTP requests can be tracked by this session ID even without Cookie.
Tomcat 3.3 is the de facto standard of Servlet 2.2/JSP 1.1 implementation.
Based on the enthusiastic efforts by the cool Apache developers, Tomcat 3.3 provides a very sophisticated modular design, which allows the Servlet container to be customized by adding and removing modules that control the processing of Servlet requests. Now, Tomcat 3.3 gets the significance performance improvements.
By this state-of-art implementation of Servlet 2.2/JSP 1.1, our Servlet/JSP can offer better web-based or WAP-based services than ever.
This Java Swing example shows JToolBar with Actions on BorderLayout. The Action on JToolBar can be embed into JMenuItem on JMenu. And both of JButton on JToolBar and JMenuItem on JMenu can be toggled at the same time.
This JavaMail example for JSP and Servlet creates a simple web mail system. You can download the source code of this web mail at FREE, i.e. you can build a simple web mail system by JSP and Servlet on Apache Tomcat.
The e-mails downloaded from POP3 server or sent to SMTP server can be listed on JSP. The contents of the e-mails can be displayed on JSP. Thus, the JSP in this example plays a part of GUI in MVC design. The user of this web mail system can edit the e-mail on JSP. Some Servlet in this example is responsible for sending the e-mail through SMTP server by JavaMail API. The user of this web mail system can also move the e-mails around the folders. Another Servlet in this example executes the JDBC PreparedStatement to move the e-mails between the folders. In this example, Servlet always plays a role of Model in MVC design. After the Servlet finishes its work, the request is forwarded to the JSP, which reflects the updated Model.
An object in the ServletContext on Java Servlet can update its enclosing data by accessing SQL database through EJB or JDBC periodically. Our Servlets can get the latest data without the connection to the the SQL.
Tomcat3.1 is the implementation of JavaServerPages1.1 and Servle2.2 specification and developed and maintained by the Jakarta Project.
Building Apache1.3.12 itself easy. But in case many modules need to be compiled with Apache, it is important to take the appropriate procedure. Except for the standard modules which are supplied with Apache source tree, we should carefully examine how to compile them. In this documentation, I'll describe how to compile the following external (non-standard) modules:
This article describes how to use JOnAS (Enhydra) EJB server with MySQL. JOnAS is the implementation of EJB specification Version 1.1, which supports JTA (Java Transaction API). And JOnAS requires JDBC 2.0 compatible driver, including the transaction. But MySQL supports the transaction (BEGIN, COMMIT and ROLLBACK) only in some situation. In the environment where the transaction is not supported, some configuration may be required to work with JOnAS EJB (Enterprise Java Beans) server. But don't worry. MM.MySQL JDBC driver is prepared for JOnAS.
This documentation describes how to store 2 bytes String into MySQL. MySQL is the world fastest SQL database. Though MySQL can be compiled for some specific character set (charset), such as Japanese ShiftJIS, it is desirable to store String with multiple charsets. For example, SQL database for e-commerce should accept Chinese GB2312 as well as Japanese EUC-JP. With MM.MySQL JDBC driver for MySQL, we can store Java String with 2 bytes characters, such as Japanese Shift_JIS, Chinese BIG5 or GB2312. JDBC PreparedStatement can be executed to query by Japanese language or Chinese on MySQL compiled just for ASCII. By OOP-Research.
We, the developers in the Tomcat developer mailing list), have talked about the Servlets Specification v2.2 and JSP Specification v1.1, and I resumed my proposal based on such a discussion. I'm eager to hear your opinion to my proposal!
This document describes about setting up Tomcat3.1Beta with JServ. Patch for Tomcat3.1Beta is also available in this page.
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.