Generic Service – HTML Form Post to Email Servlet

This article is about a generic service that takes a simple HTML Form Post and turns it into an Email. It is not revolutionary – but useful nevertheless. Besides, it is the first installment in a series that works towards a SOA implementation. We will implement a Business Process in this series using Oracle BPEL PM 10.1.3. The first step in this process is a Web Site (in this case even a static HTML document), that posts a form with the collected user input. The Form Submit – and therefore the sent email – is the trigger that starts the process.

We will see in this article how we can post an HTML form to any URL, in this specific case one that represents a generic Java Servlet but in the exact same manner also a PHP, PERL, ASP.NET or any other CGI like web application, that turns it into a an email. The HTML Document is completely decoupled from this Email Service – very SOA style!

The business case under scrutiny in this series revolves round the Conference Organisation Administration (COA). Conference visitors can register for the conference on the website. This registration triggers the backoffice process – by sending an email – crude but effective and still quite common!

This website – in this example represented by a static HTML document – allows users to register for the (fictitious) SOA and BPEL Conference.

The HTML Form in this static document posts to some generic servlet, somewhere on the internet:

This Form must contain at least three parameters that are used by the servlet to send an email containing all form values posted by the conference registeree. In this case – my own email address (jellema@amis.nl) is the one to which the email composed from the HTML Form Post is sent.

The servlet processes the Posted Parameters and composes an email that is subsequently sent to the addressee specified in the form. This likely an email account that is monitored by a backoffice clerk, the BPEL process activation agent – or a more simplistic poller – that initiates the back office process.

The email is sent and received by the Back Office.

It contains the values of all parameters in the Registration Form:

HTMLFormPost2EmailServlet

The Servlet taking care of the processing of the HTML Form Post into an email is quite simple. We have the Servlet itself that makes use of an even simpler Emailer Class. Note that functionality was the primary aim of this code – more so than elegant and properly refactored code design.

2 Comments

Sam, It is not hugely different, except for a few things: – it is supported by all browsers, as it does not rely on the widely varying implementation of the mailto action – it creates – depending on the servlet of course – a nicer email message (not just one long line with all data); an enhanced version of the servlet can even create an XML document in the Email body – I did not know about the mailto action until you wrote your comment. So thanks for the enlightenment.

meta

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 206 other subscribers

Email Address

About

AMIS is internationally recognized for its deep technological insight in Oracle technology. This knowledge is reflected in the presentations we deliver at international conferences such as Oracle OpenWorld, Hotsos and many user conferences around the world. Our AMIS Technology Blog, the most referred Oracle technology knowledge base outside the oracle.com domain. However you arrived here, we appreciate your interest in AMIS. Link to our Google+ Profile AMIS