title: Is it possible to reroute a Jersey JSP template response to an InputStream?
body: <p>All,</p>
  
  <p>I am using Java/Jersey 1.9 to create a web service that generates XML.  I'm generating XML using a JSP template (explicitly via the Viewable class).  Is there any way to reroute the JSP results to a local InputStream for further processing?  At the moment I'm actually calling my own XML web service as an http loopback (localhost) from a different method.</p>
  
  <p>Thanks for any insights,</p>
  
  <p>Ian</p>
  
  <pre><code>@GET @Path("kml")
  @Produces("application/vnd.google-earth.kml+xml")
  public Viewable getKml(
          @QueryParam("lat") double lat,
          @QueryParam("lon") double lon,
          @QueryParam("alt") double alt) {
  
      overflights = new SatelliteOverflightModel(
              context, new SatelliteOverflightModel.Params(lat, lon, alt)
              ).getOverflights();
  
      return new Viewable("kml", this);
  }
  
  @GET @Path("kmz")
  @Produces("application/vnd.google-earth.kmz")
  public InputStream getKmz(@Context UriInfo uriInfo,
          @QueryParam("lat") double lat,
          @QueryParam("lon") double lon,
          @QueryParam("alt") double alt)
          throws IOException {
  
      Client client = Client.create();
      WebResource webr = 
              client.resource(uriInfo.getBaseUri()+"overflights/kml");
      InputStream result =
              webr.queryParams(uriInfo.getQueryParameters()).get(InputStream.class);
  
      // Do something with result; e.g., add to ZIP archive and return
  
      return result;
  }
  </code></pre>