I ask as I was using javax.mail to handle file upload on a browser(?!) amd
although it worked, ot was VERY slow.
Using code like this, inside a doPost():
Properties props = System.getProperties();
Session session = Session.getDefaultInstance(props, null);
// Dummy up a message header.
String headers
= "Content-Type: " + request.getContentType() +
"\r\n\r\n";
InputStream messageIS =
new SequenceInputStream(new StringBufferInputStream(headers),
request.getInputStream());
System.out.println("Processing "+new java.util.Date().toString());
try
{
MimeMessage message = new MimeMessage(session, messageIS);
System.out.println("Got MimeMessage");
Object content = message.getContent();
if (content instanceof MimeMultipart)
{
MimeMultipart mm = (MimeMultipart) content;
System.out.println("Its multipart");
int nBodyParts = mm.getCount();
for (int i = 0; i < nBodyParts; i++)
{
BodyPart part = mm.getBodyPart(i);
System.out.println("Filename="+part.getFileName());
}
processRequest(request, response);
}
}
catch (MessagingException ex)
{
}
System.out.println("End "+new java.util.Date().toString());
On my Athlon850, not a slow machine, with JDK1.3, uploaded a 1.5 meg file in
5 minutes!!!!
Using hand cranked code to parse the incoming stream takes 40 seconds.
What gives?
The submitted jsp was like this:
<html>
<head><title>File upload</title></head>
<body>
<%! int count=0; %>
<%
System.out.println(count);
count++;
%>
Please upload your pension data here<BR>
<FORM ACTION="/servlet/com.javelin.swinglets.demo.FileUploadServlet2"
METHOD=POST ENCTYPE="multipart/form-data" >
What is your name? <INPUT TYPE=TEXT NAME=submitter> <BR>
Which file to upload? <INPUT TYPE=FILE NAME=file> <BR>
<INPUT TYPE=SUBMIT>
</FORM>
<FORM ACTION="/servlet/com.javelin.swinglets.demo.FileUploadServlet"
METHOD=POST ENCTYPE="multipart/form-data">
Which special file to upload? <INPUT TYPE=FILE NAME=file2> <BR>
<INPUT TYPE=SUBMIT>
</FORM>
</body>
</html>
The first version went to the javax.mail uploaded, the second to my hand
cranked uploaded. The biggest hit was turning the
input stream into a mime message, 5 minutes.
I was thinking, perhaps javax.mail is ok for sending, and for receiving
personal emails, but not up to the job for handling large volumes?
Has anyone looked at the code for creating a mime message from a stream?
Seems odd that its 7.5 times slower than my own code,
which I thought was pretty damn slow before I tried the javax.mail method.
Dino.
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/>
Problems?: [EMAIL PROTECTED]