01.01.2013 Views

CICS Transaction Gateway V5 The WebSphere ... - IBM Redbooks

CICS Transaction Gateway V5 The WebSphere ... - IBM Redbooks

CICS Transaction Gateway V5 The WebSphere ... - IBM Redbooks

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

358 <strong>CICS</strong> <strong>Transaction</strong> <strong>Gateway</strong> <strong>V5</strong><br />

<strong>The</strong> action of the HTML form is to call the servlet CTGTesterCCIServlet, using<br />

the POST method to send the parameters. This means that the parameters are<br />

sent in the HTTP request body. Because an HTTP POST request is intended to<br />

affect some sort of change on the Web server, a Web browser will prompt to<br />

resubmit the data if the user clicks Refresh on the results page. Conversely, the<br />

GET method could be used, which sends the parameters on the HTTP request<br />

URL. Because HTTP GETs are not intended to alter anything on the Web server,<br />

the results page of such a request can be refreshed without a prompt being<br />

shown.<br />

Servlet<br />

In the following section, we describe the major code sections in the<br />

CTGTesterCCIServlet servlet and how the servlet functions. <strong>The</strong> servlet is stored<br />

in the CTGTesterCCIWeb enterprise application project in <strong>WebSphere</strong> Studio.<br />

<strong>The</strong> servlet is defined to be in the package itso.cics.j2ee.eci.testercci. It is<br />

stored in the folder source/itso/cics/j2ee/eci/testercci in <strong>WebSphere</strong> Studio.<br />

Figure B-20 shows the import statements used to give us access to the Java<br />

packages used in the servlet. <strong>The</strong> import of javax.servlet and<br />

javax.servlet.http give us access to the Java Servlet API set of classes; the<br />

import of javax.naming gives us access to the JNDI library; the import of<br />

javax.rmi gives us access to the Java Remote Method Invocation library; the<br />

imports of java.io, java.util, and java.text are required for utility classes<br />

used in the servlet; the import of com.ibm.ctg.client provides the <strong>CICS</strong> TG<br />

Java class library.<br />

import javax.servlet.http.*;<br />

import javax.servlet.*;<br />

import javax.naming.*;<br />

import javax.rmi.*;<br />

import java.util.Date;<br />

import java.util.StringTokenizer;<br />

import java.io.UnsupportedEncodingException;<br />

import java.io.IOException;<br />

import java.text.DateFormat;<br />

import java.text.SimpleDateFormat;<br />

Figure B-20 Import statements<br />

Figure B-21 shows the opening code section of our servlet. We extend the<br />

HTTPServlet class to make our class an HTTP protocol servlet. Following this we<br />

then first declare our instance variables and objects, which are variables that we<br />

wish to share across all threads running within the servlet.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!