Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 30900 invoked from network); 23 Jul 2004 17:52:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 23 Jul 2004 17:52:16 -0000 Received: (qmail 90299 invoked by uid 500); 23 Jul 2004 17:52:11 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 89956 invoked by uid 500); 23 Jul 2004 17:52:09 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 89942 invoked by uid 99); 23 Jul 2004 17:52:09 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [66.162.134.137] (HELO jerry.networkeleven.net) (66.162.134.137) by apache.org (qpsmtpd/0.27.1) with ESMTP; Fri, 23 Jul 2004 10:52:04 -0700 Received: from [216.174.112.17] (helo=PSGIIB) by jerry.networkeleven.net with esmtp (Exim 4.34) id 1Bo4DD-0003eD-6r for commons-user@jakarta.apache.org; Fri, 23 Jul 2004 10:52:03 -0700 From: "Thomas Joseph Olaes" To: Subject: [FileUpload] Question re Sample Code for MultipartStream class (what is OutputStream output for?) Date: Fri, 23 Jul 2004 10:51:47 -0700 Message-ID: <000601c470dd$be3f0160$0e93030a@cisnet> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2616 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - jerry.networkeleven.net X-AntiAbuse: Original Domain - jakarta.apache.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - olaes.net X-Source: X-Source-Args: X-Source-Dir: X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hello List, This is my first email post to the group. My question regarding the example code listed at the top of the MultipartStream class javadoc page: What is OutputStream output for? Is it for the "out" variable? I'm getting an error with my current code saying I have to initialize it... how do I do this? I was reading through the javadoc and supposedly readBodyData(OutputStream) is supposed to give the outputstream a value, but is there some kind of initialization I have to do before hand? Like point the OutputStream towards the "out" variable somehow? I've messed around with the example correcting the errors and stuff, declaring variables and giving them instances, and I just want to get something that works on Tomcat so I can fiddle with it and see what the different functions do. So far I have: <%@ page session="false" %> <%@ page import="org.apache.commons.fileupload.*" %> <%@ page import="java.lang.*" %> <%@ page import="java.io.*" %> <%@ page import="java.util.*" %>
<%
if(FileUpload.isMultipartContent(request)){
  // request is a multipart/form-data,
javax.servlet.http.HttpServletRequest Interface Object
  out.println("lalala");

  //Enumeration eHeaderNames = new Enumeration;
  
  InputStream input = request.getInputStream(); // new InputStream();
  byte[] boundary = new byte[4096];
  
  String header;

  try {
    MultipartStream multipartStream = new MultipartStream(input,
boundary);
    boolean nextPart = multipartStream.skipPreamble();
    OutputStream output;
    PrintWriter pw = new PrintWriter(output);
    
    while(nextPart) {
      header = multipartStream.readHeaders();
      // process headers


      // create some output stream
      multipartStream.readBodyData(output);
      nextPart = multipartStream.readBoundary();
    }
  }
  catch(MultipartStream.MalformedStreamException e) {
    // the stream failed to follow required syntax
  } catch(IOException e) {
    // a read or write error occurred
  }
}
%>
" />
" />
" />

rest What I'm trying to do ultimately is get the file in myfileupload to upload a text file which I will later parse, but I can't get the file upload to work so I'm trying to figure out how to get that part going. What I've resorted to is starting with this example code, correcting errors, defining variables before the code piece runs, and just generally trying to get something working. I'm hoping to get help from this mailing list, but if not I will keep looking through the javadocs and fumbling my way through the darkness. Thanks in advance for the help! -TJ --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org