Package javax.servlet

Examples of javax.servlet.ServletOutputStream


        }
      }
    }
   
    req.response.setContentType("text/plain");
    ServletOutputStream os = req.response.getOutputStream();
    IOUtils.write(result.toString(), os, "UTF-8");
    os.close();
  }
View Full Code Here


        throw new ServletException("Error removing ontology from graph", e);
      }
    }

    req.response.setContentType("text/plain");
    ServletOutputStream os = req.response.getOutputStream();
    IOUtils.write(result, os);
    os.close();
  }
View Full Code Here

    if ( mime != null ) {
      response.setContentType(mime);
    }

    FileInputStream is = new FileInputStream(file);
    ServletOutputStream os = response.getOutputStream();
    IOUtils.copy(is, os);
    os.close();
  }
View Full Code Here

     
      if ( log.isDebugEnabled() ) {
        log.debug(this.getClass().getName()+ ": dispatching with outFormat=" +ontReq.outFormat);
      }

      ServletOutputStream os = ontReq.response.getOutputStream();

      ///////////////////////////////////////////////////////////////////
      // OWL
      if ( ontReq.outFormat.equalsIgnoreCase("owl")
      ||   ontReq.outFormat.equalsIgnoreCase("rdf")
      ) {
        if ( log.isDebugEnabled() ) {
          log.debug(this.getClass().getName()+ ": Serializing to RDF/XML-ABBREV");
        }
        ServletUtil.setContentTypeRdfXml(ontReq.response);
//        is = OntServlet.serializeModel(model, "RDF/XML-ABBREV");
        OntServlet.serializeModelToOutputStream(model, "RDF/XML-ABBREV", os);
      }
     
      ///////////////////////////////////////////////////////////////////
      // N3
      else if ( ontReq.outFormat.equalsIgnoreCase("n3") ) {
        ServletUtil.setContentTypeTextPlain(ontReq.response);
        OntServlet.serializeModelToOutputStream(model, "N3", os);
      }
     
      ///////////////////////////////////////////////////////////////////
      // NT
      else if ( ontReq.outFormat.equalsIgnoreCase("nt") ) {
        ServletUtil.setContentTypeTextPlain(ontReq.response);
        OntServlet.serializeModelToOutputStream(model, "N-TRIPLE", os);
      }
     
      ///////////////////////////////////////////////////////////////////
      // TTL
      else if ( ontReq.outFormat.equalsIgnoreCase("ttl") ) {
        ServletUtil.setContentTypeTextPlain(ontReq.response);
        OntServlet.serializeModelToOutputStream(model, "TURTLE", os);
      }
     
      ///////////////////////////////////////////////////////////////////
      // HTML
      else if ( ontReq.outFormat.equalsIgnoreCase("html") ) {
       
        // Redirect to the appropriate service.
       
        String ontologyUri;
       
        if ( ontReq.ontology != null ) {
          ontologyUri = ontReq.ontology.getUri();
        }
        else if ( ontReq.mmiUri != null ) {
          // Note: drop any extension here (the Orr service will do the appropriate request
          // back to this Ont service):
          ontologyUri = ontReq.mmiUri.getOntologyUriWithExtension("");
        }
        else {
          ontologyUri = ontReq.fullRequestedUri;
        }
       
        String portalServiceUrl = OntConfig.Prop.PORTAL_SERVICE_URL.getValue();
       
        String url = portalServiceUrl+ "/#" +ontologyUri;
        if ( log.isDebugEnabled() ) {
          log.debug("REDIRECTING TO: " +url);
        }
        String redir = ontReq.response.encodeRedirectURL(url);
        ontReq.response.sendRedirect(redir);
        return;
      }
     
      ///////////////////////////////////////////////////////////////////
      // BAD REQUEST
      else {
        ontReq.response.sendError(HttpServletResponse.SC_BAD_REQUEST,
            "ModelResponse: outFormat " +ontReq.outFormat+ " not recognized"
        );
        return;
      }
     
      os.close();
    }
View Full Code Here

        response.setHeader("Cache-Control","must-revalidate, post-check=0, pre-check=0");
        response.setHeader("Pragma", "public");
        response.setHeader("Content-disposition", "attachment;filename="+ fileName + ".pdf");
        response.setContentLength(baos.size());
       
        ServletOutputStream out = response.getOutputStream();
        baos.writeTo(out);
        out.flush();
    }
View Full Code Here

    if ( externalName != null ) {
      response.setHeader("Content-Disposition", "attachment; filename=" +externalName);
    }
   
    InputStream is = new FileInputStream(file);
    ServletOutputStream os = response.getOutputStream();
    IOUtils.copyLarge(is, os);

    os.flush();
    os.close();
  }
View Full Code Here

    status = HttpServletResponse.SC_OK;
    characterEncoding = "UTF-8";
    locale = null;

    byteStream = new ByteArrayOutputStream();
    servletStream = new ServletOutputStream()
    {
      @Override
      public void write(int b)
      {
        byteStream.write(b);
View Full Code Here

                content = false;
            }

        }

        ServletOutputStream ostream = null;
        PrintWriter writer = null;

        if (content) {

            // Trying to retrieve the servlet output stream
View Full Code Here

                if (type != null) {
                    response.setContentType(type);
                }
            }
           
            ServletOutputStream os = response.getOutputStream();
            IOUtils.copy(is, os);
            os.flush();
        } catch (IOException ex) {
            throw new ServletException("Static resource " + pathInfo
                                       + " can not be written to the output stream");
        }
       
View Full Code Here

  public void testStaticResources_jQuery() throws Exception {
    HttpServletResponse resp = createMock(HttpServletResponse.class);
    resp.setContentType("text/javascript");
    resp.setHeader("Cache-Control", "public; max-age=300");
    ServletOutputStream sos = createMock(ServletOutputStream.class);
    expect(resp.getOutputStream()).andReturn(sos);
    sos.write((byte[]) EasyMock.anyObject(), EasyMock.eq(0), EasyMock.anyInt());
    EasyMock.expectLastCall().atLeastOnce();
    sos.flush();
    EasyMock.expectLastCall().anyTimes();
    replay(resp, sos);
    MapReduceServletImpl.handleStaticResources("jquery.js", resp);
    verify(resp, sos);
  }
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.