OOP-ResearchMake It Simpler by Object Oriented Programming

Java API and examples by XML : Simpler than JSP/JSTL, Apache Struts or JavaServer Faces : Input validation from CGI FORM : Localization (L10n) : Servlet in Japanese Shift_JIS, Chinese BIG5 or GB2312

Java API and examples by XML. Simpler than JSP/JSTL, Apache Struts or JavaServer Faces. Input validation from CGI FORM. Localization (L10n). Servlet in Japanese Shift_JIS, Chinese BIG5 or GB2312.
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 page lists the Java API and examples by HtmlToXml.

Related Pages:


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


PRODUCT:OOP ViewGenerator

In the template framework design by OOP ViewGenerator API, all the response can be generated from the normal HTML (or any other mark-up languages such as XHTML, WML or HDML). 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. They can write the view part of the web applications in the normal HTML, by their favorite ways.

HTML-to-XML conversion tool (with Java Swing GUI) converts the normal HTML into the template XML. You can also specify the acceptable data type for the request parameters from the CGI FORM:

HtmlToXml
[HtmlToXml]

Once you finish the conversion, please place the generated XML into:

  • (docBase)/WEB-INF/classes

directory (or its sub-directories). Then, ViewGenerator API in your Servlet will read it. Your Servlet can insert the arbitrary Strings into the HTML fragments and send the concatenated HTML tags to the web browser. Because the XML includes the acceptable data types from the CGI FORM, a few lines of code are enough for the input validation in your Servlet.

In addition, this Java API makes the localization (L10n, Japanese message for Japanese users and Chinese message for Chinese users) of your Servlet much easier. In case of Apache Struts or JavaServer Faces, the localized messages should be written in the property resource file for the expected Locale. But, 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.



Back to Top Read More

DOC:First example of ViewGenerator API

This is the first-step example of OOP ViewGenerator API. This source code example consists of 2 Servlet:

  • example.formgen1.Cgi
  • example.formgen1.Verify

The first one generates the empty CGI FORM.

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
[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.



Back to Top Read More

DOC:Second example of ViewGenerator API

This is the second example of OOP ViewGenerator 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 ViewGenerator 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.
[Input validation for U.S.]

But it should be 12-34-56-78-90 in France:

Input validation for 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, ViewGenerator API makes the things very easy.



Back to Top Read More

PRODUCT:OOP RequestParser

This Java API parses the HTTP request parameters in the effective way. It also implements the methods to access the URL-encoded request parameters, or the request parameters in the byte array.
To get the better performance, this API postpones the conversions among the URL-encoded parameters, the byte arrays and decoded String until they are really required. By this strategy, Servlet can get the HTTP request parameters in the various forms.
Please download and try this Java API. It's FREE!



Go Site Map Read More

PRODUCT:OOP ServletWorker

Apache Tomcat behind the Apache web server (HTTP daemon) can accept the HTTP request for more than one host. With this Java API, Servlet can take the advantage of this feature.
The HTTP request to Apache web server can be redirected to Jakarta Tomcat, and the same Servlet object can accept the HTTP request for more than one host. This feature can prevent the unnecessary resource consumption, but the same response for every host is not enough. By the help of this API, Servlet can process the HTTP request in the different way for each host.
Please download and try this Java API. It's FREE!



Go Site Map Read More

PRODUCT:OOP ConfigPerHost

For some set of initialization parameters, the different values should be set for each host, when the single instance of Tomcat accepts the HTTP requests to multiple hosts. But, as for another set of initialization parameters, you may want to set the same value for all the hosts. By this API, both of these types of initialization parameters can be defined in the single XML. In addition to the typical types of values, such as int or String, the XML can define the Set and arrays of them. And this API implements the methods to get the initialization parameters in the Set or arrays.
Please download and try this Java API. It's FREE!



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.