Package javax.servlet

Examples of javax.servlet.ServletOutputStream


              "contentMime", "image/jpeg");
          res.setContentType(contentMime);
          log(getInfo(req) + "Returning request/reply image '" + contentMime + "' length="
              + msgUnitArr[0].getContent().length);
          out = null;
          ServletOutputStream binOut = res.getOutputStream();
          byte[] buff = msgUnitArr[0].getContent();
          binOut.write(buff, 0, buff.length);
          binOut.flush();
          binOut.close();
        }
        return;
      }

      /* see XbAccess.js/watchee.js for an example:
View Full Code Here


     * Get implementation - increments and shows the access count
     */
    protected void doGet(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
        numberOfGets++;
        ServletOutputStream out = response.getOutputStream();
        out.println("<html><body>This servlet has been accessed via GET "
                + numberOfGets + " times</body></html>");
        out.flush();
    }
View Full Code Here

        if (xrdsFile != null)
        {
            BufferedInputStream input = new BufferedInputStream(
                    new FileInputStream(_testDataPath + "/xrds/" + xrdsFile));

            ServletOutputStream output = response.getOutputStream();

            byte[] data = new byte[8192];
            int bytesRead = input.read(data, 0, data.length);
            while (bytesRead > 0)
            {
                output.write(data, 0, bytesRead);
                bytesRead = input.read(data, 0, data.length);
            }

            input.close();
            output.close();

        } else if (htmlFile != null) // HTML response
        {
            BufferedReader input = new BufferedReader(
                    new FileReader(_testDataPath + "/html/" + htmlFile));

            //PrintWriter output = new PrintWriter( response.getWriter());
            ServletOutputStream output = response.getOutputStream();

            String line = input.readLine();
            while (line != null)
            {
                output.println(line);
                line = input.readLine();
            }

            input.close();
            output.close();
        }

    }
View Full Code Here

    {
        if (DEBUG) _log.debug("Sending direct response:\n" + response);

        try
        {
            ServletOutputStream os = httpResp.getOutputStream();
            os.write(response.getBytes());
            os.close();
        }
        catch (IOException e)
        {
            throw new ServerException("Error generating direct verification response", e);
        }
View Full Code Here

        try
        {
            DirectError err = DirectError.createDirectError(response, compat);

            ServletOutputStream os = httpResp.getOutputStream();
            os.write(err.keyValueFormEncoding().getBytes());
            os.close();
        }
        catch (IOException e)
        {
            _log.error("Error generating direct error response", e);
        }
View Full Code Here

            if (writer!=null) throw new IllegalStateException("The variable 'out' or 'html' have been used already. Use either out/html or sout, not both.");
            if (outputStream==null) outputStream = response.getOutputStream();
            return outputStream;
        }
        public ServletOutputStream getOutputStream() {
            return new ServletOutputStream() {
                public void write(int b) throws IOException {
                    getResponseStream().write(b);                   
                }
                public void close() throws IOException {
                    getResponseStream().close();
View Full Code Here

            RemoteInvocation invocation = (RemoteInvocation) ois.readObject();
            ois.close();
            /* execute the method */
            InvocationResult result = ServiceCallHandler.execute(invocation);
            /* write the result */
            ServletOutputStream sos = response.getOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream(sos);
            oos.writeObject(result);
            oos.close();
        } catch (Throwable t) {
            /* write the exception */
            ServletOutputStream sos = response.getOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream(sos);
            oos.writeObject(new InvocationResult(t));
            oos.close();
        }
    }
View Full Code Here

    public void destroy() {}

    public void doFilter(ServletRequest request, ServletResponse response,
            FilterChain chain) throws IOException, ServletException {
        chain.doFilter(request, response);
        ServletOutputStream os = response.getOutputStream();
        os.print("Hello");
    }
View Full Code Here

  protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    BufferedImage image = (BufferedImage) model.get(LegendIconsController.IMAGE_KEY);

    // write the image
    ServletOutputStream out = response.getOutputStream();
    response.setContentType(getContentType());
    // response.setContentLength(image.); // need to write image first to know size
    ImageIO.write(image, FORMAT, out);

    out.flush();
  }
View Full Code Here

    InputStream stream = null;

    try {
      response.setContentType(layer.getFormat());
      stream = httpService.getStream(url, layer.getAuthentication());
      ServletOutputStream out = response.getOutputStream();
      int b;
      while ((b = stream.read()) >= 0 ) {
        out.write(b);
      }
    } catch (Exception e) {
      log.error("Cannot get original WMS image", e);
      // Create an error image to make the reason for the error visible:
      byte[] b = createErrorImage(layerInfo.getTileWidth(), layerInfo.getTileHeight(), e);
View Full Code Here

TOP

Related Classes of javax.servlet.ServletOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.