Matt,

The connection to the iSeries part seems to be working OK.  I ran it in debug 
this afternoon and we confirmed the information is moving between my pc and the 
iSeries.  It looks like the trouble spot may be in the session object.  It 
receives the returned data and then returns to the JSP.  When the JSP makes the 
next call to the methods in the session object to create the page to display 
the variables are blank.  Somehow they are getting initialized or cleared 
between being populated by the iSeries, returning to the JSP, and building the 
HTML returned to the JSP.

I've included the code for the session object and the JSP.

Rick


Session Source:

package arswspoc;

// This acts as a proxy for the servlet so it needs the same imports
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class DateSent_Session
{
        // Creation parms
        // Identify the servlet that invoked the session.
        HttpServlet servlet;
        
        // Server parameter
        // Identifies the server proxy that will be used.
        DateSent_Server server;
        
        // Bean variables
        // These are the instance variables, which are used to communicate
        // with the user.  Defailt values are stored for the initial display.
        private String ACCT = "";
        private String RTNDATE = "";
        private String button = "";

        // URL constants
        // These constants identify the JSP to use during the application and
        // the index URL to invoke when the application ends.
        private static final String index = "index.html";
        private static final String page1 = "DateSent.jsp";

// Default constructor which is not used
public DateSent_Session() {
        super();
}

// Constructor used to save the servlet so it can be used to forward the 
// requests to the proper URL
public DateSent_Session(HttpServlet servlet) {
        super();
        this.servlet = servlet;
}

// Create a new instance of the server proxy and then forward to the JSP 
public void doGet(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException
{
        server = new DateSent_Server();
        servlet.getServletContext().getRequestDispatcher(page1).forward(req, 
res);
}

// The bulk of the work is done here
// putValues() stores the results of the POST operation into the instance
// variables.
public void doPost(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException
{
        putValues(req);
        String url;
        
        if (button.equals("Exit"))
        {
                server.shutdown();
                url = index;
        }
        else
        {
                try {
                        putValues(server.run(getValues()));
                } catch(Exception e) {
                        throw new ServletException(e.getMessage());
                }

                url = page1;
        }

        servlet.getServletContext().getRequestDispatcher(url).forward(req, res);
}

// This method is used by the JSP to get the appropriate HTML for a field
public String getFormattedField(String fieldName)
{
        String value = null;
        
        if (fieldName.equals("ACCT"))
                value = formatInput("ACCT", ACCT, 12);
        else if (fieldName.equals("RTNDATE"))
                value = RTNDATE;

        return value;
}

// Build the HTML input tag
// This is what causes the input box to display on the page
private String formatInput(String name, String value, int size)
{
        return 
                "<input type=text name=" + name +
                " value=\"" + value + "\"" +
                " maxlength=" + size +
                " size=" + size + ">";
}

// Build an array of objects, which are converted to a data structure
// and passed to the server proxy.
private Object[] getValues() {
        return new Object[] { ACCT, RTNDATE };
}

// Take an array of objects returned from the server proxy
// and store them into instance variables.
// Move returned information from proxy objects to page variables?
private void putValues(Object value) {
        Object[] values = (Object[]) value;
        ACCT = (String) values[0];
        RTNDATE = (String) values[1];
        }

// This is used to retieve the user's input and update
// the instance variables prior to being ssent ot the server proxy.
private void putValues(HttpServletRequest req) {
        button = (String) req.getParameter("button");
        ACCT = (String) req.getParameter("ACCT");
}
}

JSP source:

<html>

<head>
<meta http-equiv="expires" content=" ">
<title>Radio Letters</title>
</head>

<body>

<%
  try {
%>

<jsp:useBean class="arswspoc.DateSent_Session" id="datesent_session" 
scope="session">
</jsp:useBean>

<H2>ARS Web Service Proof of Concept</H2>

<form method="post">

Enter Account: <%= datesent_session.getFormattedField("ACCT") %><br>
The date sent is <%= datesent_session.getFormattedField("RTNDATE") %>
<p>

<input name="button" type="submit" value="Run">&nbsp;
<input name="button" type="submit" value="Exit">
</form>

<%
  } catch (Exception e) {
    out.println("<P><B>Error in DateSent.jsp</B><P>");
    out.println("<pre>");
    e.printStackTrace(new java.io.PrintWriter(out));
    out.println("</pre>");
  }
%>


</body>

</html>


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.