Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help for downloads  RSS feed

 
vivek sivakumar
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well i have a jsp page which can display a list of documents , well if the user clicks on the document then im showing it on a separate jsp page , well what i need is that if document is greater than 40 mb then i should prompt the user to download it ...
<%
if (file.length()> 41940000)
{
// please insert ur code help here !!!
}
 
Joe Gilvary
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about
<%
if (file.length()> 41940000)
{
// please insert ur code help here !!!
out.print("<strong>This file is "
+ String.valueOf(file.length())
+ " bytes.");
out.print("Click <a href=\"ftp://url.to.file\">"
+ "here</a> to download it.");
}
%>
An ftp: link will prompt the user to choose
a local filename, and you can "warn" them ahead
of time by showing the file size on your page.
Hope that helps.
Joe
 
vivek sivakumar
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well this snippet does not seems to work as its not printing a link , well is there a syntax error in the above snippet .
 
Joe Gilvary
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vivek,
I used it in a page before I sent it. You'll need to
put a real url in the href, but I don't know any reason
why the brower wouldn't recognize an ftp: link.
I just cut the snippet out of the previous post and tried
it again. It creates a link to the (non existent) url
"url.to.file" on my server.
Is the prompt for the file.length() printing? Maybe the
file you're using isn't that large?
Thanks,
Joe
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!