You should read these troubleshooting tips if you receive a Java Servlet Output Binary Error Code.
How to fix Windows crashes
I am trying to write a huge Java Servlet retrieved from binary result requests and respond to them by eliminating the use of
HttpServletRequest.getOutputStream () and
HttpServletResponse.getInputStream () . This affects project a, which sends the actual request from the Silverlight borrower, to which this servlet responds over an HTTP POST connection. To test this servlet, I first implement a Java client that I know better than Silverlight.
The problem is that in my test project I am sending certain data from a servlet client because I have a byte array and I expect you to get a byte array of the same length - only that will never happen, and instead I am getting a new single byte. So I am definitely posting relevant pieces in the drawings that you can show me where I am wrong and hopefully provide relevant bibliography to help us further.
The client servlet handles POST requests outside of a very simple HTML page with a pretty form that I am using in this frontend. I'm not too concerned about using JSP etc., but rather defining communication between servlets.
// HttpServlet client calls this method away from doPost (request, response)private cancellation request, process (HttpServletRequest response HttpServletResponse)throws ServletException, IOException String firstName = (String) request.getParameter ("name"); String lastName = (string) request. getparameter ("last name"); String xmlRequest = "
"; OutputStream-Writer = zero; InputStream-Reader = zero; try Weblink url = new url ("http: // localhost: 8080 / project / server"); URLConnection conn = url.openConnection (); conn.setDoInput (true); conn.setDoOutput (true); Writer means comp. getoutputstream (); byte  baXml is xmlRequest.getBytes ("UTF-8"); write.write (baXml, 0, baXml.length); write.flush (); // Can I wait here? How? "Or" What? matches the player conn.getInputStream (); int = disk is available. accessible(); byte  data = young byte [available]; reader.read (data, 0, available); String xmlResponse = String (data, "UTF-8"); Substitution PrintWriter print implies response.getWriter (); print.write (" Answer:
"); print.write (xmlResponse); print.write ("
"); Hurry. Close(); finally if (writer! = zero) Writer.close (); If (disk! = Null) Reader.close ();
The server handles HTTP POST requests from the servlet. To do this, the above requests are handled by the servlet client for testing purposes, but in the future I intend to finally use it for clients in other languages (especially Silverlight).
// Server-side HttpServlet creates this method from doPost (request, response)private rejection process (HttpServletRequest, HttpServetResponse response)throws ServletException, IOException ServletInputStream sis = null; To think about sis is the same as request.getInputStream (); // I should probably use a large BufferedInputStream // but straight from an InputStream? Int available implies sis.available (); a byte  entry implies a new byte [available]; int readBytes = sis.read (input, 0, available); if (readBytes! = available) throw a new ServletException ("Oops! readBytes! = availableBytes"); // I ONLY RECEIVE 1 BYTE OF DATA !!! // This is the actual client byte, message '<'. The msg string matches "Read" + Read Bytes + "Bytes From" + available + "available + available upon request by InputStream." ; System.err.println ("Server.process (HttpServletRequest, HttpServletResponse):" + message); String xmlReply = "
" + msg + ""; byte personalX data  = xmlReply.getBytes ("UTF-8"); ServletOutputStream sos = response.getOutputStream (); sos.write (data, 0, data length); sos.flush (); SOS. Close(); finally if (sis! = zero) sis.close ();
So far I've been content with byte arrays instead of running
BufferInputStreamas I haven't yet determined if I'll base64 encode strings, for example, to convey information and facts. , or if I was using unmodified binary data.
Speed up your PC today with this easy and free download.