 |
: Product by OOP-Research |
 |
: Documentation written by OOP-Research |
 |
: Patch for the other vendor's system |
First example of FormGenerator API
This is the first-step example of OOP FormGenerator API.
This source code example consists of 2 Servlet:
- example.formgen1.Cgi
- example.formgen1.Verify
The first one generates the empty CGI FORM.
[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.
[CGI FORM with invalid input]
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.
In this source code example, all the response from Java Servlet (web application GUI, or View part of MVC (Model View Controller)) can be generated from the normal HTML (or any mark up language such as XHTML, WML and HDML).
Unlike the JSP/JSTL based solution (such as Apache Struts or JavaServer Faces), all the response can be written in just the HTML tags.
The web designers (or page authors) need not learn even a bit of custom tag libraries in JSP/JSTL.
Once the HTML is prepared, the Java Swing GUI based conversion tool generates the XML.
While in the conversion, you will be asked to specify the acceptable data type for each request parameter from the CGI FORM.
Given this XML, a few lines of codes will be enough for the input validation in your Servlet.
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.
In this example, we add the additional text input to the CGI FORM of the first example.
The new text field in this example asks the user to enter the telephone number.
The expected pattern of the telephone number differs with the countries.
In U.S., the telephone number is something like 123-456-7890:
[Input validation for U.S.]
But it should be 12-34-56-78-90 in France:
[Input validation for 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
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.
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.
This example uses XMLPanelEdit. XMLPanelEdit consists of Java Swing GUI tool (Java Swing GUI builder) and abstract Java classes. Java Swing GUI tool included in XMLPanelEdit is the XML editor, by which you can define the nested structure of your Java Swing GUI in XML. By this XML editor, you can specify any LayoutManager on JPanel, JFrame or JDialog, i.e. you can select FlowLayout, BorderLayout, BoxLayout or GridLayout.
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.
For example, when the user modifies the text on JTextArea, JButton for saving the file should be activated on JToolBar. At the same time, the JMenuItem for saving the file will also be activated in JMenu.
To be notified of the modification in JTextArea, DocumentListener should be added into Document of the JTextArea.
This example uses XMLPanelEdit. XMLPanelEdit consists of Java Swing GUI tool (Java Swing GUI builder) and abstract Java classes. Java Swing GUI tool included in XMLPanelEdit is the XML editor for representing the JFC Swing GUI in XML.
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.
Most of these Java APIs are Thread Safe and only a single instance is enough within each web application context.
Due to these characteristics, our Java APIs have very similar interfaces.
Once you are familiar with any of them, you can easily use the rest of them.
It is another benefit of Java API from OOP-Research.
This article describes the Tips for JSP/Servlet programming by Java API from OOP-Research.
The source code of a example Servlet is also listed here.
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 article is the How To for setting up Tomcat 3.3 in a secure way.
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.
In this Java Swing GUI example, we will build some very simple text editor.
When the user modifies the text on JTextArea, JButton for saving the file should be activated.
And we'd like to place this interactive JButton both on JToolBar and JMenuItem.
To make it possible, we will allocate the same Action to JToolBar and JMenuItem.
By enabling and disabling the single Action instance, JButton on JToolBar and its corresponding JMenuItem can be toggled at the same time.
JToolBar should be placed on JPanel with BorderLayout.
And to be notified of the modification in JTextArea, DocumentListener should be added into Document of the JTextArea.
This Java Swing example also shows the internationalization (i18n) of JFC Swing GUI by ResourceBundle read from the property resource file.
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.
With the JServ module installed, the Apache http server redirects some of the http request to the JServ servlet engine. This means our servlets can be invoked through the Apache http server. This is cool, ins't it?
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:
- libssl.so
- mod_frontpage.so
- libperl.so
- libdav.so
- mod_fastcgi.so
- libphp3.so
- mod_jserv.so
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.
|