You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by Martin West <ma...@objectgizmos.com> on 2008/09/22 15:00:27 UTC
cactus and servletconnection
Does anyone have a sample of testing SerlvetConnection with Cactus
aka ...
URLConnection servletConnection = servletURL.openConnection();
// to allow us to write to the URL ...
servletConnection.setDoOutput(true);
// to ensure that we do contact
// the servlet and don't get
// anything from the browser's cache
servletConnection.setUseCaches(false);
servletConnection.setDefaultUseCaches(false);
// Write the message to the servlet
PrintStream out = new PrintStream(servletConnection
.getOutputStream());
out.println(cmd);
out.println(subcmd);
out.println(s);
out.close();
// Now read in the response
StringBuffer buffer = new StringBuffer();
InputStream in = servletConnection.getInputStream();
int chr;
while ((chr = in.read()) != -1) {
buffer.append((char) chr);
}
in.close();
Could not see anything in the docs/samples
Thanks
--
regards
Martin West