Examples of MultipartResponse


Examples of com.oreilly.servlet.MultipartResponse

                    // Set the filename, is used when the file will be saved (problem with mozilla)
                    response.addHeader( "Content-Disposition",
                                        "attachment; filename=" + shortFileName);
               
                    // Constructing the multi part response to the client
                    MultipartResponse multipartresponse = new MultipartResponse(response);
               
                    // Is the convert type HTML?
                    if ( ( multipartrequest.getParameter( "converttype" ).equals(
                               "swriter: HTML (StarWriter)" ) )
                         || ( multipartrequest.getParameter( "converttype" ).equals(
                                  "scalc: HTML (StarCalc)" ) ) ) {
                        // Setting the content type of the response being sent to the client
                        // to text
                        multipartresponse.startResponse( "text/html" );
                    } else {
                        // Setting the content type of the response being sent to the client
                        // to application/octet-stream so that file will open a dialog box
                        // at the client in order to save the converted file
                        multipartresponse.startResponse( "application/octet-stream" );
                    }
                   
                    // Pushing the converted file to the client
                    ServletUtils.returnFile( stringConvertedFile,
                                             response.getOutputStream() );
                   
                    // Finishing the multi part response
                    multipartresponse.finish();
                   
                    // clean up the working directory
                    cleanupFile = new File(stringConvertedFile);
                    if ( cleanupFile.exists() )
                        cleanupFile.delete();
View Full Code Here

Examples of com.oreilly.servlet.MultipartResponse

        stringWorkingDirectory + stringFilename,
        multipartrequest.getParameter( "converttype" ),
        multipartrequest.getParameter( "extension" ) );

        // Constructing the multi part response to the client
        MultipartResponse multipartresponse = new MultipartResponse(
        response );
       
        // Is the convert type HTML?
        if ( ( multipartrequest.getParameter( "converttype" ).equals(
        "swriter: HTML (StarWriter)" ) )
        || ( multipartrequest.getParameter( "converttype" ).equals(
        "scalc: HTML (StarCalc)" ) ) ) {
          // Setting the content type of the response being sent to the client
          // to text
          multipartresponse.startResponse( "text/html" );
        } else {
          // Setting the content type of the response being sent to the client
          // to application/octet-stream so that file will open a dialog box
          // at the client in order to save the converted file
          multipartresponse.startResponse( "application/octet-stream" );
        }
       
        // Pushing the converted file to the client
        ServletUtils.returnFile( stringConvertedFile,
        response.getOutputStream() );

        // Finishing the multi part response
        multipartresponse.finish();
      }
    }
    catch (Exception exception) {
      System.err.println( exception.toString() );
    }
View Full Code Here

Examples of com.oreilly.servlet.MultipartResponse

                    // Set the filename, is used when the file will be saved (problem with mozilla)
                    response.addHeader( "Content-Disposition",
                                        "attachment; filename=" + shortFileName);
               
                    // Constructing the multi part response to the client
                    MultipartResponse multipartresponse = new MultipartResponse(response);
               
                    // Is the convert type HTML?
                    if ( ( multipartrequest.getParameter( "converttype" ).equals(
                               "swriter: HTML (StarWriter)" ) )
                         || ( multipartrequest.getParameter( "converttype" ).equals(
                                  "scalc: HTML (StarCalc)" ) ) ) {
                        // Setting the content type of the response being sent to the client
                        // to text
                        multipartresponse.startResponse( "text/html" );
                    } else {
                        // Setting the content type of the response being sent to the client
                        // to application/octet-stream so that file will open a dialog box
                        // at the client in order to save the converted file
                        multipartresponse.startResponse( "application/octet-stream" );
                    }
                   
                    // Pushing the converted file to the client
                    ServletUtils.returnFile( stringConvertedFile,
                                             response.getOutputStream() );
                   
                    // Finishing the multi part response
                    multipartresponse.finish();
                   
                    // clean up the working directory
                    cleanupFile = new File(stringConvertedFile);
                    if ( cleanupFile.exists() )
                        cleanupFile.delete();
View Full Code Here

Examples of com.oreilly.servlet.MultipartResponse

                    // Set the filename, is used when the file will be saved (problem with mozilla)
                    response.addHeader( "Content-Disposition",
                                        "attachment; filename=" + shortFileName);
               
                    // Constructing the multi part response to the client
                    MultipartResponse multipartresponse = new MultipartResponse(response);
               
                    // Is the convert type HTML?
                    if ( ( multipartrequest.getParameter( "converttype" ).equals(
                               "swriter: HTML (StarWriter)" ) )
                         || ( multipartrequest.getParameter( "converttype" ).equals(
                                  "scalc: HTML (StarCalc)" ) ) ) {
                        // Setting the content type of the response being sent to the client
                        // to text
                        multipartresponse.startResponse( "text/html" );
                    } else {
                        // Setting the content type of the response being sent to the client
                        // to application/octet-stream so that file will open a dialog box
                        // at the client in order to save the converted file
                        multipartresponse.startResponse( "application/octet-stream" );
                    }
                   
                    // Pushing the converted file to the client
                    ServletUtils.returnFile( stringConvertedFile,
                                             response.getOutputStream() );
                   
                    // Finishing the multi part response
                    multipartresponse.finish();
                   
                    // clean up the working directory
                    cleanupFile = new File(stringConvertedFile);
                    if ( cleanupFile.exists() )
                        cleanupFile.delete();
View Full Code Here

Examples of com.oreilly.servlet.MultipartResponse

        stringWorkingDirectory + stringFilename,
        multipartrequest.getParameter( "converttype" ),
        multipartrequest.getParameter( "extension" ) );

        // Constructing the multi part response to the client
        MultipartResponse multipartresponse = new MultipartResponse(
        response );
       
        // Is the convert type HTML?
        if ( ( multipartrequest.getParameter( "converttype" ).equals(
        "swriter: HTML (StarWriter)" ) )
        || ( multipartrequest.getParameter( "converttype" ).equals(
        "scalc: HTML (StarCalc)" ) ) ) {
          // Setting the content type of the response being sent to the client
          // to text
          multipartresponse.startResponse( "text/html" );
        } else {
          // Setting the content type of the response being sent to the client
          // to application/octet-stream so that file will open a dialog box
          // at the client in order to save the converted file
          multipartresponse.startResponse( "application/octet-stream" );
        }
       
        // Pushing the converted file to the client
        ServletUtils.returnFile( stringConvertedFile,
        response.getOutputStream() );

        // Finishing the multi part response
        multipartresponse.finish();
      }
    }
    catch (Exception exception) {
      System.err.println( exception.toString() );
    }
View Full Code Here

Examples of com.oreilly.servlet.MultipartResponse

                    // Set the filename, is used when the file will be saved (problem with mozilla)
                    response.addHeader( "Content-Disposition",
                                        "attachment; filename=" + shortFileName);
               
                    // Constructing the multi part response to the client
                    MultipartResponse multipartresponse = new MultipartResponse(response);
               
                    // Is the convert type HTML?
                    if ( ( multipartrequest.getParameter( "converttype" ).equals(
                               "swriter: HTML (StarWriter)" ) )
                         || ( multipartrequest.getParameter( "converttype" ).equals(
                                  "scalc: HTML (StarCalc)" ) ) ) {
                        // Setting the content type of the response being sent to the client
                        // to text
                        multipartresponse.startResponse( "text/html" );
                    } else {
                        // Setting the content type of the response being sent to the client
                        // to application/octet-stream so that file will open a dialog box
                        // at the client in order to save the converted file
                        multipartresponse.startResponse( "application/octet-stream" );
                    }
                   
                    // Pushing the converted file to the client
                    ServletUtils.returnFile( stringConvertedFile,
                                             response.getOutputStream() );
                   
                    // Finishing the multi part response
                    multipartresponse.finish();
                   
                    // clean up the working directory
                    cleanupFile = new File(stringConvertedFile);
                    if ( cleanupFile.exists() )
                        cleanupFile.delete();
View Full Code Here

Examples of com.oreilly.servlet.MultipartResponse

        stringWorkingDirectory + stringFilename,
        multipartrequest.getParameter( "converttype" ),
        multipartrequest.getParameter( "extension" ) );

        // Constructing the multi part response to the client
        MultipartResponse multipartresponse = new MultipartResponse(
        response );
       
        // Is the convert type HTML?
        if ( ( multipartrequest.getParameter( "converttype" ).equals(
        "swriter: HTML (StarWriter)" ) )
        || ( multipartrequest.getParameter( "converttype" ).equals(
        "scalc: HTML (StarCalc)" ) ) ) {
          // Setting the content type of the response being sent to the client
          // to text
          multipartresponse.startResponse( "text/html" );
        } else {
          // Setting the content type of the response being sent to the client
          // to application/octet-stream so that file will open a dialog box
          // at the client in order to save the converted file
          multipartresponse.startResponse( "application/octet-stream" );
        }
       
        // Pushing the converted file to the client
        ServletUtils.returnFile( stringConvertedFile,
        response.getOutputStream() );

        // Finishing the multi part response
        multipartresponse.finish();
      }
    }
    catch (Exception exception) {
      System.err.println( exception.toString() );
    }
View Full Code Here

Examples of org.mortbay.servlet.MultiPartResponse

  private void outputScannerEntryMime(final HttpServletResponse response,
    final ScannerRecord sr)
  throws IOException {
    response.setStatus(200);
    // This code ties me to the jetty server.
    MultiPartResponse mpr = new MultiPartResponse(response);
    // Content type should look like this for multipart:
    // Content-type: multipart/related;start="<rootpart*94ebf1e6-7eb5-43f1-85f4-2615fc40c5d6@example.jaxws.sun.com>";type="application/xop+xml";boundary="uuid:94ebf1e6-7eb5-43f1-85f4-2615fc40c5d6";start-info="text/xml"
    String ct = ContentType.MIME.toString() + ";charset=\"UTF-8\";boundary=\"" +
      mpr.getBoundary() + "\"";
    // Setting content type is broken.  I'm unable to set parameters on the
    // content-type; They get stripped.  Can't set boundary, etc.
    // response.addHeader("Content-Type", ct);
    response.setContentType(ct);
    // Write row, key-column and timestamp each in its own part.
    mpr.startPart("application/octet-stream",
        new String [] {"Content-Description: row",
          "Content-Transfer-Encoding: binary",
          "Content-Length: " + sr.getKey().getRow().getBytes().length});
    mpr.getOut().write(sr.getKey().getRow().getBytes());

    // Usually key-column is empty when scanning.
    if (sr.getKey().getColumn() != null &&
        sr.getKey().getColumn().getLength() > 0) {
      mpr.startPart("application/octet-stream",
        new String [] {"Content-Description: key-column",
          "Content-Transfer-Encoding: binary",
          "Content-Length: " + sr.getKey().getColumn().getBytes().length});
    }
    mpr.getOut().write(sr.getKey().getColumn().getBytes());
    // TODO: Fix. Need to write out the timestamp in the ordained timestamp
    // format.
    byte [] timestampBytes = Long.toString(sr.getKey().getTimestamp()).getBytes();
    mpr.startPart("application/octet-stream",
        new String [] {"Content-Description: timestamp",
          "Content-Transfer-Encoding: binary",
          "Content-Length: " + timestampBytes.length});
    mpr.getOut().write(timestampBytes);
    // Write out columns
    outputColumnsMime(mpr, sr.getValue());
    mpr.close();
  }
View Full Code Here

Examples of org.mortbay.servlet.MultiPartResponse

  private void outputRowMime(final HttpServletResponse response,
      final Map<Text, byte[]> result)
  throws IOException {
    response.setStatus(result.size() > 0? 200: 204);
    // This code ties me to the jetty server.
    MultiPartResponse mpr = new MultiPartResponse(response);
    // Content type should look like this for multipart:
    // Content-type: multipart/related;start="<rootpart*94ebf1e6-7eb5-43f1-85f4-2615fc40c5d6@example.jaxws.sun.com>";type="application/xop+xml";boundary="uuid:94ebf1e6-7eb5-43f1-85f4-2615fc40c5d6";start-info="text/xml"
    String ct = ContentType.MIME.toString() + ";charset=\"UTF-8\";boundary=\"" +
      mpr.getBoundary() + "\"";
    // Setting content type is broken.  I'm unable to set parameters on the
    // content-type; They get stripped.  Can't set boundary, etc.
    // response.addHeader("Content-Type", ct);
    response.setContentType(ct);
    outputColumnsMime(mpr, result);
    mpr.close();
  }
View Full Code Here

Examples of org.openqa.jetty.http.MultiPartResponse

        //  content-length header
        //
        ResourceCache.ResourceMetaData metaData =
            (ResourceCache.ResourceMetaData)resource.getAssociate();
        String encoding = metaData.getMimeType();
        MultiPartResponse multi = new MultiPartResponse(response);
        response.setStatus(HttpResponse.__206_Partial_Content);
        response.setReason((String)HttpResponse.__statusMsg
                           .get(TypeUtil.newInteger(HttpResponse.__206_Partial_Content)));

  // If the request has a "Request-Range" header then we need to
  // send an old style multipart/x-byteranges Content-Type. This
  // keeps Netscape and acrobat happy. This is what Apache does.
  String ctp;
  if (request.containsField(HttpFields.__RequestRange))
      ctp = "multipart/x-byteranges; boundary=";
  else
      ctp = "multipart/byteranges; boundary=";
  response.setContentType(ctp+multi.getBoundary());

        InputStream in=(resource instanceof CachedResource)
            ?null:resource.getInputStream();
        OutputStream out = response.getOutputStream();
        long pos=0;
           
        for (int i=0;i<ranges.size();i++)
        {
            InclusiveByteRange ibr = (InclusiveByteRange) ranges.get(i);
            String header=HttpFields.__ContentRange+": "+
                ibr.toHeaderRangeString(resLength);
            if(log.isDebugEnabled())log.debug("multi range: "+encoding+" "+header);
            multi.startPart(encoding,new String[]{header});

            long start=ibr.getFirst(resLength);
            long size=ibr.getSize(resLength);
            if (in!=null)
            {
                // Handle non cached resource
                if (start<pos)
                {
                    in.close();
                    in=resource.getInputStream();
                    pos=0;
                }
                if (pos<start)
                {
                    in.skip(start-pos);
                    pos=start;
                }
                IO.copy(in,out,size);
                pos+=size;
            }
            else
                // Handle cached resource
                resource.writeTo(out,start,size);
           
        }
        if (in!=null)
            in.close();
        multi.close();

        request.setHandled(true);

        return;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.