OOP-ResearchMake It Simpler by Object Oriented Programming

OOP FormGenerator API : Simpler than JSP, JSTL, Apache Struts or JavaServer Faces / Input validation from CGI FORM / Easy localization (L10n) / Servlet in Japanese Shift_JIS, Chinese BIG5 or GB2312

Servlet by template 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.
In the framework design by OOP FormGenerator API, all the Servlet response can be written in the normal HTML or any other mark-up languages (such as XHTML, WML or HDML). Unlike the JSP/JSTL based solution such as Apache Struts or JavaServer Faces, the web designers (or page authors) need not learn a bit of the custom tag libraries.
This Java API makes the localization (L10n) 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.
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.

To show you how to use this Java API, the following examples are running on our web site.

Please try these example and download their source code.

This API is deprecated. Please use OOP ViewGenerator instead of this API.

Related Pages:


This API is deprecated.

Please use OOP Bento Framework instead of this API. Within OOP Bento Framework, you can deploy all the existing XML for this API. This means that OOP Bento Framework takes over all the benefits of this API.

Servlet response by the normal HTML!

Believe or not, all the response from your Servlet can be written in just the normal HTML (or any mark-up languages such XHTML, WML or HDML)! Unlike the JSP/JSTL based solutions like Apache Struts or JavaServer Faces, the web designers (or page authors) of your project need not know even a bit of the custom tag libraries. Once the response is written in the normal HTML, it's time to run HtmlToXml conversion tool:

HtmlToXml
[HtmlToXml]

This Java Swing GUI based conversion tool generates the template XML for the Servlet response. Once you generate the template XML, you can edit it by HtmlToXmlEdit, another GUI tool in this Java API.

HtmlToXmlEdit
[HtmlToXmlEdit]

Both of these tools are included in OOP FormGenerator API. When you work with these tools, please save the template XML into:
  • (docBase)/WEB-INF/classes
or its sub-directories so that your Servlet can read it. To generate the dynamic response, your Servlet can insert the arbitrary Strings between the HTML tags. Then, your Servlet can send the concatenated HTML tag to the web browser. For example, the source code of your Servlet will look like this:


    private static FormGenerator gen=null;

    public void init()
	throws ServletException{
	try{
	    gen=FormGenerator.getInstance();
	}
	catch(Exception ex){
	    ex.printStackTrace();
	    throw (new ServletException(ex));
	}
    }

    public void doGet(HttpServletRequest req, HttpServletResponse res)
	throws ServletException,IOException{

	try{
	    Form hello=gen.getForm("xml/hello.xml");
            hello.setDefaultValue("time",(new Date()).toString());
	    res.setContentType(hello.getContentType());
	    PrintWriter out=res.getWriter();
	    out.print(hello.getMerged());
	    gen.reuseForm(hello);
	    out.flush();
	    out.close();
	}
	catch(Exception ex){
	    throw (new ServletException(ex));
	}
    }


This Servlet reads the template XML which is saved as:
  • (docBase)/WEB-INF/classes/xml/hello.xml
and inserts the current time into the HTML tag in it. Then, it sends back the concatenated HTML tag to the web browser. Makes your life easier by OOP FormGenerator API!
Go Site Map

Input validation from CGI FORM by XML

While interacting with the user, each text field in your CGI FORM expects the specific pattern of input. For example, the user should type only the digit (0-9) in some text field of your CGI FORM. If s/he sends the wrong input, the destination Servlet should detect it and show the same CGI FORM again. But the CGI FORM at this time should include all the previous inputs in it as the default value. In addition, the wrong input should be indicated by the colored font or something:

CGI FORM with invalid input
[CGI FORM with invalid input]

By the help of OOP FormGenerator API, a few lines of code are enough for the input validation in your Servlet.
When you work with HtmlToXml, you can specify the acceptable data type for each request parameter from the CGI FORM:

Acceptable data type for request parameter
[Acceptable data type for request parameter]

Along with the set of the HTML tags, these information are also written into the template XML. Given these information from the XML, your Servlet can check all the request parameters at once. For details about the input validation, please try and download the first example of OOP FormGenerator API:
Go Site Map

Easy localization (L10n)

In case of the JSP/JSTL based solutions like Apache Struts or JavaServer Faces, the localized messages should be written in the property resource file for each Locale. In the template solution by OOP FormGenerator API, the localization (L10n) of your Servlet is much easier. Please prepare the normal HTML in as many human languages as you like (each of them will includes the localized message for the expected Locale). Because all the localized messages can written in the normal HTML, there is no difficulty even in the 2 byte characters such as Japanese Shift_JIS, Chinese BIG5 or GB2312.

Once you prepare the set of the HTML, please run HtmlToXml conversion tool on the HTML for each Locale. As a result, you will get the XML for each Locale. For example, your template XML will look like below:

  • (docBase)/WEB-INF/classes/xml/hello_en.xml
  • (docBase)/WEB-INF/classes/xml/hello_fr.xml
  • (docBase)/WEB-INF/classes/xml/hello_de.xml
  • (docBase)/WEB-INF/classes/xml/hello.xml
Then, by the help of OOP FormGenerator API, your Servlet can select the XML appropriate for the Locale. For details about localization (L10n), please try and download the first example of OOP FormGenerator API:
Go Site Map

Performance improvement by pooling mechanism:

When the FormGenerator object reads the XML, all the information in the XML are cached in the pool. So, the same XML is read only once within the life cycle of the Servlet.
In addition, the FormGenerator object has the pool for the Form objects. Only if no free instance of Form is available in this pool, the new Form object will be created.

Pooling the instances of Form


These pooling mechanism ensure the significance performance improvement of your Servlet.

Go Site Map

Download:

-- 90.00 USD with 1 year FREE upgrade
-- Or FREE 15 days trial

You can try or purchase this product at Java API Shop by OOP-Research.

Go Site Map Go Shop

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.