AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem to download a file from 2 browsers at the time

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
prado
Guest





PostPosted: Mon Jun 19, 2006 9:45 pm    Post subject: Problem to download a file from 2 browsers at the time Reply with quote



I have this JSP that download an excel file.

It works fine if I use only one browser at the same time.


The problem is when I try to do this but from 2 browsers at the same
time. From each browser I can download a part of the file but not the
complete file.
It seems the browsers are sharing the bandwidth and when it starts to
download a file the other stops.

I have look the logs, and I saw the file has downloaded to the computer

and while the the jsp is working.
I don't undestand why the file has finished to download and while the
jsp is still executing.


Can you help me please?

do anybody try this JSP and tell me if the result is the same as me?

------------------------------------------JSP
-----------------------------------------------------------------------------------

<%@page contentType="application/vnd.ms-excel"%>


<%@ page language="java" import="java.io.*"%>
<%@ page language="java" import="java.util.*"%>

<%


Date fecha = new Date();


java.sql.Date fechaSQL = new java.sql.Date(fecha.getTime());


Calendar calendario = Calendar.getInstance();
calendario.setTime(fecha); // fecha es el Date de antes.
String strHour = String.valueOf( calendario.get(Calendar.HOUR) );
String strMinute = String.valueOf( calendario.get(Calendar.MINUTE) );
String strSecond = String.valueOf( calendario.get(Calendar.SECOND) );

String nombre = "FILE" + strHour + strMinute + strSecond + ".xls";


System.out.println( " IN OF " + nombre );

response.setContentType( "application/x-download" );


response.setHeader("Content-type","application/vnd.ms-excel");


response.setHeader("Content-Disposition","attachment; filename=\""
+ nombre + "\"");



System.out.println( nombre + " START" );

for (int l=0;l<30000;l++){
System.out.println( nombre + " " + l );

for (int k=0;k<250;k++){



out.write(nombre + " : ("+ l + "," + k + ")" + "\t" );

}
out.write("\n");

}


System.out.println( nombre + " END" );


%>
Back to top
prado
Guest





PostPosted: Tue Jun 20, 2006 2:31 pm    Post subject: Re: Problem to download a file from 2 browsers at the time Reply with quote



Please, I need help with this problem.

Thanks.
Back to top
jcsnippets.atspace.com
Guest





PostPosted: Wed Jun 21, 2006 2:02 am    Post subject: Re: Problem to download a file from 2 browsers at the time Reply with quote



"prado" <bernadelpradoclaves (AT) yahoo (DOT) es> wrote in message
news:1150795899.876829.308990 (AT) i40g2000cwc (DOT) googlegroups.com...
Quote:
Please, I need help with this problem.

First of all, don't think we ignore you if we don't reply - it's possible
that nobody has a clear answer for your problem, or nobody has encountered
this behaviour.

Second, have your tried the following (as I do not have a solution at the
moment):
- download with different browsers?
- download, wait until finished, download with other browser?
- experiment with browser cache settings?

You mentioned log files - which log files? What did you come up with?

Some time ago, I wrote a servlet which served up .csv files, reports
generated on a database. Should you need it, I'll try to dig it up again.

Best of luck,

JayCee
--
http://jcsnippets.atspace.com/
a collection of source code, tips and tricks
Back to top
KiLVaiDeN
Guest





PostPosted: Wed Jun 21, 2006 4:19 am    Post subject: Re: Problem to download a file from 2 browsers at the time Reply with quote

prado wrote:
Quote:
I have this JSP that download an excel file.

It works fine if I use only one browser at the same time.


The problem is when I try to do this but from 2 browsers at the same
time. From each browser I can download a part of the file but not the
complete file.
It seems the browsers are sharing the bandwidth and when it starts to
download a file the other stops.

I have look the logs, and I saw the file has downloaded to the computer

and while the the jsp is working.
I don't undestand why the file has finished to download and while the
jsp is still executing.


Can you help me please?

do anybody try this JSP and tell me if the result is the same as me?

------------------------------------------JSP
-----------------------------------------------------------------------------------

%@page contentType="application/vnd.ms-excel"%


%@ page language="java" import="java.io.*"%
%@ page language="java" import="java.util.*"%

%


Date fecha = new Date();


java.sql.Date fechaSQL = new java.sql.Date(fecha.getTime());


Calendar calendario = Calendar.getInstance();
calendario.setTime(fecha); // fecha es el Date de antes.
String strHour = String.valueOf( calendario.get(Calendar.HOUR) );
String strMinute = String.valueOf( calendario.get(Calendar.MINUTE) );
String strSecond = String.valueOf( calendario.get(Calendar.SECOND) );

String nombre = "FILE" + strHour + strMinute + strSecond + ".xls";


System.out.println( " IN OF " + nombre );

response.setContentType( "application/x-download" );


response.setHeader("Content-type","application/vnd.ms-excel");


response.setHeader("Content-Disposition","attachment; filename=\""
+ nombre + "\"");



System.out.println( nombre + " START" );

for (int l=0;l<30000;l++){
System.out.println( nombre + " " + l );

for (int k=0;k<250;k++){



out.write(nombre + " : ("+ l + "," + k + ")" + "\t" );

}
out.write("\n");

}


System.out.println( nombre + " END" );


%


Hi,

I think it's much more efficient to implement the file downloading
mechanism in a Servlet, I don't think it's a good idea to put that kind
of code in a JSP.

Then, I'm wondering about that code you posted. Is it really generating
a valid XLS file ? And where is your "download" script ?

I'd advice you to read this tutorial :
http://www.onjava.com/pub/a/onjava/excerpt/jebp_3/index1.html?page=1

I think it'll give you a good hint on how to make your download Servlet.

K
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.