cURL / Mailing Lists / curl-users / Single Mail

curl-users

Curl Post to HTML served via Tomcat connects to JSP by doesn't affect backend servlet

From: Linda Toth <lttoth_at_alaska.edu>
Date: Fri, 17 Jul 2009 10:02:40 -0800

Hello

I have a java servlet that can be accessed via a JSP post when the URL is
entered in the Firefox browser, but won't post to the servlet when using the
command line for cURL. The want to access the servlet from both a web
browser with actual inputs and from a command line batch. I wrote a
"silent" JSP that will take the required input on the command line and
forward it to the servlet.

I log from the servlet when it is accessed, which is how I know it is acting
on the inputs. I also log in the JSP and the curl command line does enter
the JSP, does process every thing as expected, but then fails to post to the
action URL. I have tried both the post and get formats shown in the cURL
documentation. I have searched for any clues based on the page being
managed by Tomcat, but have had no luck. Originally the file was a JSP,
which posted similar results. I converted it to HTML with Javascript, with
the same results - each will post from the web page to the servlet when
invoked from Firefox, both appear to complete without error, but do not
touch the servlet. Any thoughts would be greatly appreciated.

BTW, I also wrote a Java program to open the connection. It appeared to
open the connection successfully, with no errors, but similarly did not log
from the servlet.

** Here are the commands I've entered:

curl "
http://localhost:8080/gae/administerBatch.jsp?batchFile=/Users/lttoth/user_batch"<http://localhost:8080/gae/administerBatch.jsp?batchFile=/Users/lttoth/user_batch%22>

curl -d "batchFile=/Users/lttoth/user_batch" --trace-ascii log.here
http://localhost:8080/gae/administerBatch.jsp

** Here is the results as shown on the screen:

<html>
  <head>
    <title>User Accounts: Google Nickname Management </title>
    <meta name="keywords" content="Google, Applications, accounts, UAF" />
    <link rel=StyleSheet href="style.css" type="text/css" media=screen>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="description" content="Automating Google Apps account
creation"/>

<script language="text/javascript">

function formSubmit() {
  document.batch_account_creation.submit();
}

</script>

  </head>

  <body>

    <form name="batch_account_creation"
      action="/gae/ManageUserControllerServlet"
      method="GET" >
      <input type=hidden name="errorPage" value="/silentActionResult.jsp" />
      <input type=hidden name="successPage" value="/silentActionResult.jsp"
/>
      <input type="hidden" name="reqType" value="BATCH_ACCOUNT_CREATION" />
      <input type="hidden" name="batchFile" value="/Users/lttoth/user_batch"
/>

      <input type=hidden name="actionPerformed" value=""/ >
      <script type="text/javascript">
        document.batch_account_creation.submit();
      </script>

    </form>
  </body>
</html>

** And this is the contents of the log file:

== Info: About to connect() to localhost port 8080 (#0)
== Info: Trying ::1... == Info: connected
== Info: Connected to localhost (::1) port 8080 (#0)
=> Send header, 213 bytes (0xd5)
0000: GET /gae/administerBatch.html HTTP/1.1
0028: User-Agent: curl/7.16.3 (powerpc-apple-darwin9.0) libcurl/7.16.3
0068: OpenSSL/0.9.7l zlib/1.2.3
0084: Host: localhost:8080
009a: Accept: */*
00a7: Cookie: batchFile=/Users/lttoth/user_batch
00d3:
<= Recv header, 17 bytes (0x11)
0000: HTTP/1.1 200 OK
<= Recv header, 27 bytes (0x1b)
0000: Server: Apache-Coyote/1.1
<= Recv header, 30 bytes (0x1e)
0000: ETag: W/"2054-1247770771000"
<= Recv header, 46 bytes (0x2e)
0000: Last-Modified: Thu, 16 Jul 2009 18:59:31 GMT
<= Recv header, 25 bytes (0x19)
0000: Content-Type: text/html
<= Recv header, 22 bytes (0x16)
0000: Content-Length: 2054<= Recv header, 37 bytes (0x25)
0000: Date: Thu, 16 Jul 2009 22:44:39 GMT
<= Recv header, 2 bytes (0x2)
0000:
<= Recv data, 2054 bytes (0x806)
0000: <!--. * htmlBatch.html. *. * Takes input from URL post triggered
0040: by Oracle to add or delete. * individual user vanity addresses,
0080: managed as nicknames with the . * Google API.. *. * If the nick
00c0: name management is successfully performed, the . * NicknameContr
0100: ollerServlet returns success and the action is logged. * in the
0140: silent receiving JSP. If it is not successful, the error is. *
0180: logged and the error message is sent to the GAE email team.. *.-
01c0: ->..<!-- Rendering of the HTML page begins -->.<html>. <head>.
0200: <title>User Accounts: Google Nickname Management </title> .
0240: <meta name="keywords" content="Google, Applications, accounts
0280: , UAF" />. <link rel=StyleSheet href="style.css" type="text/c
02c0: ss" media=screen>. <META http-equiv="Content-Type" content="t
0300: ext/html; charset=utf-8">. <meta name="description" content="
0340: Automating Google Apps account creation"/>..<script type="text/j
0380: avascript" >..function getQueryVariable(variable) {. var query
03c0: = window.location.search.substring(1);. var vars = query.split(
0400: "&");. for (var i=0;i<vars.length;i++) {. var pair = vars[i]

0440: .split("=");. if (pair[0] == variable) {. return pair[1]
0480: ;. }. }. alert('Query Variable ' + variable + ' not found')
04c0: ;.} ..var fileName = getQueryVariable('batchFile');.alert("The f
0500: ilename should be: " + fileName);..</script>.. </head>.. <bod
0540: y> .. <form name="batch_account_creation" . action="http
0580: ://localhost:8080/gae/ManageUserControllerServlet". method=
05c0: "POST" >. <input type=hidden name="errorPage" value="/silen
0600: tActionResult.jsp" />. <input type=hidden name="successPage
0640: " value="/silentActionResult.jsp" />. <input type="hidden"
0680: name="reqType" value="BATCH_ACCOUNT_CREATION" />. <script t
06c0: ype="text/javascript">. document.write('<input type="hidden
0700: " name="batchFile" value="' + fileName + '" >');. </script>
0740: .. <input type=hidden name="actionPerformed" value=""/ >.
0780: <script type="text/javascript"> . document.batch_acco
07c0: unt_creation.submit();. </script>.. </form>. </body>.</
0800: html>.
== Info: Connection #0 to host localhost left intact
== Info: Closing connection #0

-- 
Linda Toth
University of Alaska - Office of Information Technology (OIT) - Application
Services
Bunnell Building - 303 Tanana Drive, Room 231
Fairbanks, Alaska 99775-7700
+1 907.450.8332 | +1 907.474.5910
Linda.Toth_at_alaska.edu | www.alaska.edu/oit/cas
<http://www.alaska.edu/oit.cas>

-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-07-17