RequestServer (pattern 3.a)

This has another servlet that takes browser input by asking for weather information. Then, it uses pattern 3.a to send the message into the system engine. This routes the message to another Java thread, WeatherClient. This pattern has the Java code in RequestServer send the message into the engine and wait for reply. The WeatherClient thread creates the weather information, routes it back, and then sends a message back to MessageServer to store a copy there.

Note the use of the API sendToCloverleafAndWait() in this section from GetWeather.java:

package com.infor.cloverleaf.javadriver.samples.requestserver;
...
public class GetWeather extends HttpServlet {
       protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        String zipCode = request.getParameter("ZIP_CODE");
        if (!zipCode.matches("[0-9]{5}(-[0-9]{4})?"))
            throw new ServletException("The zip code field must resemble a zip code.  You provided '" + zipCode + "'.");
        String driverControl = "{MSG_KEY " + zipCode + "}";
        FromCloverleafMessage weatherResponse;
        // create the message
        try {
            ToCloverleafMessage toCloverleafMessage = new ToCloverleafMessage(request.getParameter("USER_DATA"), driverControl, MessageTypeEnum.DATA, "GET_THE_WEATHER", null, zipCode);
            weatherResponse = ToCloverleafLink.sendToCloverleafAndWait(10000, toCloverleafMessage);
        } catch (Exception ex) {
            throw new ServletException ("failed to either create the message or send it to Cloverleaf", ex);
        }