OOP-ResearchMake It Simpler by Object Oriented Programming

OOP RequestStore API: Saves HTTP request parameters into SQL table through JDBC

This Java API stores the HTTP request parameters into the SQL table through JDBC. The unique ID is issued for each request, and another Servlet/JSP can use it to get the parameter values later.
Within the SQL table, the parameter values are stored in the form of URL-encoded String. Regardless of the configuration of the SQL database, the request parameters in the various charsets (including the 2 byte character such as Japanese Shift_JIS, Chinese BIG5, Chinese GB2312 or Russian KOI8-R) can be stored into the single database. This strategy also eliminates the unnecessary byte-to-String conversion.

Putting it all togather : OOP Bento framework

This Java API is now a part of OOP Bento framework. In this MVC framework by XML, you can write all the GUIs in the web application in the normal HTML, XHTML, WML, HDML or any other mark-up languages. And you no longer need to bother about the user authentication and the session tracking. Because its full working source code example will be the good starting point of this Java API, please also try OOP Bento framework.

Related Pages:


HTTP Request persistence by JDBC ...

When the user fills the CGI FORM and clicks the button, the HTTP request with a set of request parameters is sent to your JSP/Servlet. With this API, just a single method call is enough to persist all the HTTP request parameters. At this time, the unique ID is issued for each HTTP request. And your JSP/Servlet can save this ID into the SQL table specific to your web application. The code of your JSP/Servlet will look like this:



   // Get the instance of RequestStore.
   RequestStore
      reqStore=RequestStore.getInstance();

   // Create ParsedRequestParameters object.
   ParsedRequestParameters
      params=reqParser.parseSimple(req);

   // Store all the parameters into the SQL table.
   // For example, if the user fills the CGI FROM
   // to post the message to the web log, all the items
   // (the subject, the message body and the nick name)
   // can be saved at once.
   long id=reqStore.storeSimple(params);

   // Please save the above ID into the SQL table,
   // that is specific to your web application.
   // For example, the ID can be saved along with the
   // subject of the posted message.
   ...


Later, another JSP/Servlet in your web application picks the ID, and can use it as the parameter of this API. Given the unique ID, this API retrieves the persisted HTTP request parameter(s). Another Servlet in your web application may include the lines like below:



   // Get the instance of RequestStore.
   RequestStore
      reqStore=RequestStore.getInstance();

   // Please pick the ID for the intended HTTP request.
   // For example, yet another Servlet may list the subjects
   // of the posted messages along with the corresponding IDs.
   // When the user clicks the intended subject, this Servlet
   // receives the HTTP request with its ID as the request
   // parameter.
   long id=Long.parseLong(req.getParameter("id"));

   // Retrieve all the request parameters ...
   ParsedRequestParameters
      params=reqStore.getStoredRequestSimple(id);

   // Now, let's write them into the HTML template ...
   // Get the instance of ViewGenerator first ...
   ViewGenerator view=ViewGenerator.getInstance();

   // Send the response by merging the HTTP request
   // parameters into the HTML template.
   // For example, the intended message will be shown
   // to the user.
   // And the user will see the subject, the message body
   // and the nick name within the HTML template.
   view.writeResponse(params, 0, res, null, null, false);


Note that the last 2 lines in the above example depends on OOP ViewGenerator API. As you notice, the code fragments above are independent of the original CGI FORM, i.e. you can add/delete the items in the CGI FORM without updating the source of both Servlet.

Go Site Map

Download

This API is now a part of Bento framework. There are the better documentations and source code examples on the web site for Bento framework. There, you will also find the link to download the entire framework or each API in it.

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.