- For individual users
- Instant access to solutions
- Ask your tech questions
- Start your 30-day Free Trial
Main Topics
Browse All Topics
Hi, this is a pretty important question and I am really hoping someone out there has the experience dealing with uploading, to help me out with this.
Summary. I am developing an upload application that can let a user browse for a jpeg and upload it to be stored on the server. We built something using the javazoom upload bean however for some reason when we use dialup to test the uploading it takes a very long time for the post to complete. What I mean by this, is we setup a test page with just a very basic form.
FORM
---
<form name=form1 method=post action="uploadaction.jsp" enctype="multipart/form-da
<table width="60%" border="0" cellspacing="1" cellpadding="1" align="center">
<tr>
<td align="left">
<font size="-1" face="Verdana, Arial, Helvetica, sans-serif"><b>Select a file to upload:</b></font>
</td>
</tr>
<tr>
<td align="left">
<font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
<input type="file" name="uploadFile" size="50">
</font>
</td>
</tr>
<tr>
<td align="left">
<font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
<input type="submit" name="submit" value="Upload">
<input type="reset" name="Reset" value="Cancel">
</font>
</td>
</tr>
<tr>
<td align="left">
</td>
</tr>
</table>
</form>
---
uploadaction.jsp
---
<%
out.println("Hello World!");
%>
---
What is baffling me is that we put a blank jsp page as the action, for example, in the form above, uploadaction.jsp is just a blank jsp page with
'hello world' on it.
In our internal network, from a client computer, I browse and select a files of varying sizes, and the Post takes longer and longer for each file as they get bigger. However, nothing is being uploaded. I have tried this in IIS and it happens just about instantaneously.
Over dialup, specifically AOL, the time it takes to see the hello world message increases from 2-3 seconds (30kb)... to about 5 minutes (1.5MB). I don't understand why there is such a large time difference.
Can someone offer to me an explaination to as why these Multipart/Form-Data Posts are taking so long if supposedly nothing is being uploaded. Are there settings on the Tomcat side that could be causing these delays, the only i can think of is problems reading the headers.
Does someone have realworld experience on a project that needed to deal with this? I understand that dialup will be of course slow but how does everyone else do it?
Below are some of the requirements and notes on what we are trying to do.
Requirements
Efficiency and Optimization - ability to scale to 1000's of concurrent users
Progress Bar - ability to see percentage uploaded
Allow only - JPG files
Stop transfer of files over 2MB.
No client side applet or activex control, must be able to use native browser.
Concerns, I don't want some 20 malicious users all sending 2 Gig files and crashing the server, how do we avoid that?
Currently using Javazoom Upload Bean on Tomcat on Solaris 9 (x86)
Other setups tested with the same results.
Tomcat on Windows 2000
Resin on Solaris 9
Any help, comments, best practices, suggestion would be very appreciated.
THANKS.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: vikram_1982Posted on 2004-05-21 at 03:44:01ID: 11125315
Where is the code that actually does the upload?? I dont see any reference to it.
aanam\\ima ges\\users \\";
th);
tent-Dispo sition: form-data; name=\"")) h()-1); ;
ry))
n id: *** " + request.getParameter("sess ionid")); ionid") + "_" + filename, "rw"); th - 2);
m/struts-u ser@jakart a.apache.o rg/ msg9667 3.html
Here, apparently, the form is being submitted to uploadaction.jsp and uploadaction.jsp has nothing in it but a Hello World statement. THe code for actually performing the upload should be present in this location.
THis is a upload method that i have used in my pages...
<%
//The directory where the uploaded file should be stored
String savePath = "D:\\tomcat\\webapps\\Kaly
String filename = "";
ServletInputStream in = request.getInputStream();
byte[] line = new byte[128];
int i = in.readLine(line,0,128);
int boundaryLength = i-2;
String boundary = new String(line,0,boundaryLeng
// -2 discards the newline character
while(i!=-1)
{
String newLine = new String(line,0,i);
if(newLine.startsWith("Con
{
String s = new String (line,0,i-2);
int pos = s.indexOf("filename=\"");
if (pos != -1)
{
String filepath = s.substring(pos+10,s.lengt
pos = filepath.lastIndexOf("\\")
if(pos != -1)
{
filename = filepath.substring(pos+1);
}
else
{
filename = filepath;
}
}
//this is the file content
i = in.readLine(line,0,128);
i = in.readLine(line,0,128);
//Blank Line
i = in.readLine(line,0,128); //Check the model output file in d:\tomcat\bin\demo.out
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
newLine = new String(line,0,i);
while (i != -1 && !newLine.startsWith(bounda
{
//The last line of the file content contains the new line character
//so we need to check if the line that we are currently reading is infact
//the last line or not.
buffer.write(line,0,i);
i = in.readLine(line,0,128);
newLine = new String(line,0,i);
}
try
{
//save the uploaded file
System.out.println("sessio
RandomAccessFile f = new RandomAccessFile(savePath + request.getParameter("sess
byte[] bytes = buffer.toByteArray();
f.write(bytes,0,bytes.leng
f.close();
}
catch(Exception e)
{}
}
i=in.readLine(line,0,128);
}
%>
***ALLOW ONLY JPG FILES...***
Not too sure. But i think u can check the filename extension once the file is uploaded and then reject it if it is not a JPEG extension.
***PROGRESS BAR***
http://www.mail-archive.co