I've written a public library for a project WebMail: a Web application to
send a receive text-html-nested e-mail messages using a common WEb borwser.
I use Java Servlet API, JavaMail 1.1 and Liveconnect tchnologies.
I hope you've implemented an interface of Java activation Framework called
MultipartDataSource: it semplifies your work!!
-----Messaggio originale-----
Da: Bruno Lowagie <[EMAIL PROTECTED]>
A: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Data: gioved� 11 marzo 1999 10.54
Oggetto: Re: R: HTTP-Upload


>Marcello Soffritti wrote:
>>
>> But you could use a very simple HTML form like this:
>> <FORM ACTION="..."  ENC_TYPE="multipart/form-data">
>> <INPUT TYPE="file" NAME="userfile">
>> </FORM>
>> If you want use an Applet:
>> - open a socket to the server (port 80)
>> - send an http request to get filename.cgi with post method and
>> enctype multipart/form-data
>> - open a stream to the local file and send it to the socket
>
>
>Maybe also some Servlet-code to decipher the file once you uploaded the
>file:
>
>String boundary = request.getContentType();
>if (boundary.startsWith("multipart/form-data")) {
>        try {
>                boundary = "--" +
boundary.substring(boundary.indexOf("boundary=") +
>9);
>                StringBuffer buffer = new StringBuffer();
>                BufferedReader in = request.getReader();
>                String tmp;
>                String naam = "";
>                while ((tmp = in.readLine()) != null) {
>                        if (tmp.equals(boundary + "--")) {
>                                tmp = buffer.toString().substring(0,
buffer.length() - 1);
>                                // remark: I put everything in a
SessionContainer-object which is a
>kind of Hashtable
>                                // You can choose to do this otherwise
>                                sessionContainer.put(naam, tmp);
>                                buffer = new StringBuffer();
>                        }
>                        else if (tmp.equals(boundary)) {
>                                if (! naam.equals("")) {
>                                        tmp =
buffer.toString().substring(0, buffer.length() - 1);
>                                        sessionContainer.put(naam, tmp);
>                                        buffer = new StringBuffer();
>                                }
>                                tmp = in.readLine();
>                                naam = tmp.substring(tmp.indexOf(" name=")
+ 7);
>                                naam = naam.substring(0,
naam.indexOf('"'));
>                                while (! (tmp = in.readLine()).equals(""))
{}
>                        }
>                        else if (! tmp.equals("")) {
>                                buffer.append(tmp + "\n");
>                        }
>                }
>        }
>        catch (IOException ioe) {
>                sessionContainer.put("IOException", ioe.getMessage());
>        }
>        catch (StringIndexOutOfBoundsException sioobe) {
>                sessionContainer.put("StringIndexOutOfBoundsException",
>sioobe.getMessage());
>        }
>}
>
>--
>-------------------------------------------------------------------
>Bruno Lowagie           Academisch Rekencentrum Universiteit Gent
>Tel : 09/264.48.14      e-mail : [EMAIL PROTECTED]
>-------------------------------------------------------------------
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to