A servlet relies on the Web server for accepting and handling incoming requests. Once the Web server has decided that the request is for an MQe servlet, it passes the request to MQe using the doPost() method. The following code handles this request:
C example
/** * Handle POST...... */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { // any request to process ? if (request == null) throw new IOException("Invalid request"); try { int max_length_of_data = request.getContentLength(); // data length byte[] httpInData = new byte[max_length_of_data]; // allocate data area ServletOutputStream httpOut = response.getOutputStream(); // output stream ServletInputStream httpIn = request.getInputStream(); // input stream // get the request read( httpIn, httpInData, max_length_of_data); // process the request byte[] httpOutData = channelManager.process(null, httpInData); // appears to be an error in that content- length is not being set // so we will set it here response.setContentLength(httpOutData.length); response.setIntHeader("content-length", httpOutData.length); // Pass back the response httpOut.write(httpOutData); } catch (Exception e) { // pass it on ... throw new IOException( "Request failed" + e ); } }
This method: