<java>
/**
* Copyright (c) 1998-2000 BEA Systems, Inc.  All rights reserved
*
* THIS IS SOURCE CODE PUBLISHED FOR DEMONSTRATION PURPOSES
* This JHTML file illustrates how a BankApp HTML client uses an HTTP servlet
* to access the TUXEDO BankApp INQUIRY service.
*/
</java>

<java type=import>
bea.jolt.pool.*
bea.jolt.pool.servlet.*
weblogic.jndi.*
javax.naming.*
java.util.Hashtable
java.io.IOException
</java>

<java type=class>
  private boolean b_init = false;
  private ServletSessionPoolManager b_mgr;

/**
 * Since there is no way to override the init() method, we need
 * to come up a local initialization method.
 */
private void localInit(HttpServletRequest req)
    throws ServletException
  {
    // Get the session pool manager through JNDI.
    try {
      Environment env = new Environment();
      Context ctx = env.getInitialContext();
      b_mgr =
        (ServletSessionPoolManager) ctx.lookup(SessionPoolManager.POOLMANAGER_NAME);
    }
    catch (NamingException e) {
      throw new ServletException(e.toString());
    }
  }
</java>

<java type=code>
  // Codes that are in the service() method.
  if (!b_init) {
    // Do some local initialization: get the session pool manager
    // which has initialized a session pool at WebLogic Server startup
    localInit(request);
    b_init = true;
  }

  ServletResult output;

  // Get the "demojoltpool" session pool
  ServletSessionPool session =
    (ServletSessionPool) b_mgr.getSessionPool("demojoltpool");
  if (session == null) {
</java>

<html>
<head><title>Bankapp</title></head>
<body bgcolor=#FFFFFF>
<font face="Helvetica">
<h2>
No Session Pool
</h2>

<p>
Copyright (c) 1998 BEA Systems, Inc.  All rights reserved.
</font>
</body>
</html>

<java>
    out.close();
    return;
  }

  try
    {
    // Invoke a service and get the result.  No transaction is
    // needed for services, so the 3rd parameter in this call is
    // null.  Present the result page with input and output data.

    output = session.call("INQUIRY", request, null);
</java>

<html>
<head>
<title>INQUIRY Result on
<java type=print>request.getParameterValues("ACCOUNT_ID")[0]</java></title></head>
<body bgcolor=#FFFFFF>
<font face="Helvetica">
<h2>
<font color=#DB1260>
The Result of the INQUIRY Service is:
</font>
</h2>

<table border=0>
<tr>
<td align=right><b>Account number:</b></td>
<td>
<java type=print>request.getParameterValues("ACCOUNT_ID")[0]
</java></td></tr>

<tr>
<td align=right><b>Current balance:</b></td>
<td>
<java type=print>output.getStringValue("SBALANCE", "")
</java></td></tr>

<tr><td align=right><b>Current date:</b></td><td>
<script>document.write(new Date())</script></td></tr>
</table>

<center>
<form>
<input type='button' value='Back' OnClick='history.go(-1)'>
</form>
</center>
<p>
Copyright (c) 1998 BEA Systems, Inc.  All rights reserved.

</font>
</body>
</html>

<java>
  }
  catch (SessionPoolException e) {
  // All sessions are busy
</java>

<html>
<body bgcolor=#FFFFFF>
<font face="Helvetica">

<h2>
<font color=#DB1260>
Your request could not be completed.
</font>
</h2>

<p>
Possible Reasons:
<br>
<ul>
<li>No sessions are available
<li>The session pool is suspended
<li>The session pool is shutdown
</ul>

<p>
Please re-submit your request later.
<p>
Copyright (c) 1998 BEA Systems, Inc.  All rights reserved.

</font>
</body>
</html>
<java>
  }
  catch (ApplicationException e) {
    // An application error
    output = (ServletResult) e.getResult();
</java>

<html><head><title>Application Error</title></head>
<body>
<font face="Helvetica">

<h3>
<font color=#DB1260>
Application Error
</font>
</h3>

<table border=0><tr>
<td align=right><b>Account number:</b></td>
<td><font color='#0000FF'>
<java type=print>request.getParameterValues("ACCOUNT_ID")[0]</java>
</font></td>
</tr>

<tr>
<td align=right><b>Status:</b></td>
<td><font color='#0000FF'>
<java type=print>output.getStringValue("STATLIN", "")
</java></font></td>
</tr></table>

<center>
<form>
<input type='button' value='Back' OnClick='history.go(-1)'>
</form>
</center>
<p>
Copyright (c) 1998 BEA Systems, Inc.  All rights reserved.

</font>
</body>
</html>

<java>
  }
  catch (ServiceException e) {
    // System error
</java>

<html>
<head><title>System Error</title></head>

<body bgcolor=#FFFFFF>
<font face="Helvetica">

<h3>
<font color=#DB1260>
System Error
</font>
</h3>

<table border=0>
<tr>
<td align=right><b>Error message:</b></td>
<td><font color='#0000FF'>
<java type=print>e.getMessage()</java></font></td>
</tr>

<tr>
<td align=right><b>Error number:</b></td>
<td><font color='#0000FF'>
<java type=print>e.getErrno()</java></font></td>
</tr>
</table>

<center>
<form>
<input type='button' value='Back' OnClick='history.go(-1)'>
</form>
</center>
<p>
Copyright (c) 1998 BEA Systems, Inc.  All rights reserved.

</font>
</body>
</html>
<java>
  }
  catch (Exception e) {
    // Any Java errors
</java>

<html>
<head><title>System Error</title></head>

<body bgcolor=#FFFFFF>

<h3>
<font color=#DB1260>
System Error
</font>
</h3>

<table border=0><tr>
<td align=right><b>Error message:</b></td>
<td><font color='#0000FF'>
<java type=print>e.getMessage()</java></font></td>
</tr><tr>

<td align=right><b>Error number:</b></td>
<td><font color='#0000FF'>Unknown</font></td>
</tr></table>

<center>
<form>
<input type='button' value='Back' OnClick='history.go(-1)'>
</form>
</center>
<p>
Copyright (c) 1998 BEA Systems, Inc.  All rights reserved.

</font>
</body>
</html>
<java>
  }
  out.close();
</java>
