struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Harrison" <rha...@gmail.com>
Subject Cannot Retrieve Request Parameter
Date Wed, 08 Nov 2006 17:14:05 GMT
I am trying to post a payment to a vendor and receive a response from the
vendor that the payment has been received.

Servlet "CreditCardPaymentAction" posts the payment information to the
vendor and returns null.
The postback url is "http://xxx/CreateUser.do" which maps to the
"CreateUserAction" servlet. In other words, I'm trying to post the
information to the vendor using  CreditCardPaymentAction and receive the
confirmation using CreateUserAction. The first part seems to work but, what
I get back is puzzling.

In  CreateUserAction getQueryString returns null. getParameter("xid")
returns null.
However, BufferedReader returns a jsp which contains the parameter("xid")
and its value indicating a successful transaction. The  problem is I can't
seem to retrieve it in the servlet.

I've Googled until I'm red in the face. Could someone tell me why I can't
retrieve the value for xid using getParameter("xid")? I've attached code
snippets below:

Struts-config.xml
<action path="/makePayment" input="/creditCardPayment.jsp"
name="CreditCardForm" scope="request" type="
com.beeslender.struts.CreditCardPaymentAction">
... None of the forwards are used
</action>
<action path="/createUser"  type="com.beeslender.struts.CreateUserAction">
        <forward name="create.user.success" path="/myPageSetup.do"/>
        <forward name="create.user.failure" path="/makePaymentPage.do"/>
</action>

CreditCardPaymentAction
        // Get the card information
        CreditCardForm creditCardForm = (CreditCardForm) form;
        // Assemble the credit card info for transmission to vendor
        // Constants come from properties
        StringBuffer parms = makeParms(userVO, creditCardForm, props);

        URL url = new URL(props.getString("credit.card.vendor.url"));
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        openConnection(conn);
        sendRequest(conn, parms);
        return null;

private void openConnection(HttpURLConnection conn)
    {
        conn.setDoInput(true);
        conn.setDoOutput(true);
        conn.setUseCaches(false);
    }

private void sendRequest(HttpURLConnection conn, StringBuffer parms)
    {
        DataOutputStream writer;
        conn.setRequestMethod("POST");
        conn.setRequestProperty
("Content-Type","application/x-www-form-urlencoded");
        writer = new DataOutputStream(conn.getOutputStream());
        writer.writeBytes(parms.toString());
        writer.flush();
        writer.close();
    }

CreateUserAction
        String xid = request.getParameter("xid");
        String s = request.getQueryString();
        System.out.println("The Query String is >>>>>" + s);

        BufferedReader in = new BufferedReader(request.getReader());
        String decodedString;
            while ((decodedString = in.readLine()) != null) {
                System.out.println(decodedString);
            }
        in.close();



Much Appreciated,

Bob Harrison
-- 
"In theory there is no difference between theory and practice. In practice
there is."
Yogi Berra

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message