I have a
java application that is making a request to the
tomcat and tomcat is mapping it appropriate
servlet. I am sending the XML
String to the servlet. The servlet has to deserialize the XML String, process it and return appropriate result. Below is the code for java app and servlet. When I execute this, I don't get any exceptions... but I don't get the output either.. that is... java app does not print the output..but when i comment the XStream statements I get some output. Kindly help..
I am new to XStream....
Class ContactServlet{
URL url = new URL("http://localhost:8080/VUWIServer/HelloWorldExample");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
BufferedWriter out =
new BufferedWriter( new OutputStreamWriter( conn.getOutputStream() ) );
out.write(outXML);
out.flush();
out.close();
BufferedReader in =
new BufferedReader( new InputStreamReader( conn.getInputStream() ) );
String response;
while ( (response = in.readLine()) != null ) {
System.out.println( response );
}
in.close();
}
the Servlet code:
protected void doGet( HttpServletRequest request, HttpServletResponse response )
throws ServletException, IOException {
BufferedReader bin = null;
BufferedWriter bout = null;
InputStreamReader inStream= new InputStreamReader(request.getInputStream());
bin = new BufferedReader(inStream);
String input = bin.readLine();
MsgInContainer appData = new MsgInContainer();
XStream xs = new XStream(new DomDriver());
//construct an object, appData, from the XML:
appData = (MsgInContainer)xs.fromXML(input);
String output = process(appData);
OutputStreamWriter outStream = new OutputStreamWriter(response.getOutputStream());
bout = new BufferedWriter(outStream);
bout.write(output);
bout.flush();
}