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.

public void init(ServletConfig sc) throws ServletException<br />

{<br />

// call HttpServlet init method<br />

super.init(sc);<br />

}<br />

// Set time of loading<br />

loadedDate = new Date();<br />

Figure B-5 init() method<br />

<strong>The</strong> Web application server invokes the servlet service() method upon receiving<br />

an HTTP request targeted towards that servlet. This method in turn invokes the<br />

appropriate HTTP-specific method based on the type of request.<br />

HttpServletRequest is an input parameter and contains the HTTP protocol<br />

specified header information. HttpServletResponse is an output parameter and<br />

contains an HTTP protocol-specific header and can return HTML data to the<br />

client. In our servlet we defined a doGet() and doPost() method so the servlet<br />

can handle HTTP GET and POST requests. Both methods are identical; they call<br />

the common processRequest() method, which deals with GET and POST<br />

requests in the same way.<br />

<strong>The</strong> initial section of the processRequest() method is shown in Figure B-6.<br />

public void processRequest(HttpServletRequest request,<br />

HttpServletResponse response) throws IOException<br />

{<br />

Java<strong>Gateway</strong> jgaConnection = null;<br />

// input parameters<br />

String funcName = null;<br />

String encoding = null;<br />

...<br />

String trace = "";<br />

...<br />

// the jsp to forward to for displaying the results<br />

String jsp = jspResults;<br />

// values for strings to be converted into<br />

int commareaLengthInt = 0;<br />

int gatewayDaemonPort = 2006;<br />

// retrieve parameters<br />

funcName = request.getParameter("funcName");<br />

encoding = request.getParameter("encoding");<br />

...<br />

trace = request.getParameter("trace");<br />

Figure B-6 Getting HTML form input<br />

Appendix B. Sample applications 343

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

Saved successfully!

Ooh no, something went wrong!