tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Jarman <ajar...@metacomcorp.com>
Subject Unable to POST to my servlet (DESPARATE!)
Date Sat, 16 Sep 2000 01:12:58 GMT
Hi,

I have a servlet that needs to process XML data sent from a client
browser.  The xml is not sent as a form post, but rather as direct XML.
This requires me to get the raw text sent in, so I can't use
getParameter. 

I made a simple 'Echo' servlet that simply replies back what I've sent
in.  When I run this on JDeveloper 3.1 using their WebToGo servlet
runner, it works perfectly.  When I try it in Tomcat, I don't get
anything at all.  (input is empty).  I have tried this on Tomcat 3.1,
3.2B2 and 3.2B4 with the same results.

PLEASE PLEASE somebody give me a hand.  I have a major integration to
complete this weekend, and this is the last sticking point.

I believe the Webtogo server is implementing Servlet 2.0, and Tomcat is
implementing 2.2

Any assistance is deeply appreciated.


---------------------------------------
Servlet doPost method

	public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html");
		PrintWriter out = new PrintWriter
(response.getOutputStream());
		out.println("<html>");
		out.println("<head><title>Echo</title></head>");
		out.println("<body>");

		int sizeOfBuffer = 100;
		char[] cbuf = new char[sizeOfBuffer];
		int offset = 0;
		int length = sizeOfBuffer;
		int charactersRead = 0;
		StringBuffer inputBuffer = new StringBuffer();
		BufferedReader inputStreamReader = request.getReader();

		while ( (inputStreamReader.ready()) && 
			(charactersRead = inputStreamReader.read(cbuf,
offset, length)) != -1) {
			inputBuffer.append(cbuf, offset,
charactersRead);

			// display what's coming in for debugging
			out.println("Reading... " +
inputBuffer.toString());
		}

	      inputStreamReader.close();

		out.println(inputBuffer);

		out.println("</body></html>");
		out.close();
	}


---------------------------------------
Web page that generates the input

<HTML>
  <HEAD>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html;
charset=WINDOWS-1252">
    <META NAME="GENERATOR" CONTENT="Oracle JDeveloper">
    <TITLE>XML Protocol Adapter - Test 1: Submitting SOAP or HTTP/HTML
content</TITLE>
  </HEAD>

  <BODY>
    <INPUT TYPE="text" ID="server" STYLE="width: 100%;"
VALUE="http://db2.metacomcorp.bogus:8080/servlet/adapter"/>
    <TEXTAREA ROWS="5" STYLE="width: 100%;"
ID="request">&lt;browse/&gt;</TEXTAREA>
    <BUTTON ONCLICK="var http = new ActiveXObject('Microsoft.XMLHTTP');
                     http.open('POST', document.all.server.value,
false);
                     http.send(document.all.request.value);
                     document.all.result.value = http.responseText;"
            >Send</BUTTON>
    <TEXTAREA ROWS="15" STYLE="width: 100%;" ID="result">Result goes
here.</TEXTAREA>
  </BODY>
</HTML> 

Mime
View raw message