I have a web application build on Tomcat and J2EE application server. (JSP/Servlet <---> EJBs <---> Database)
In my web business, the application will generate a txt file and present it to the user. I prepare to provide three ways to aproach this:
1- Send a mail attaching the file;
2- Display the file content as upon the request;
3- Give a hyper link in web page, allow the user download it immediatly.
The 1 and 2 are easy to implement, but how to do 3? Should J2EE write a physical file or Servlet? How to manage the files while hundred people send the request to apply their own files?
Could u help me?
Thanks a lot!
-
How to present file to user in Web based J2EE application (6 messages)
- Posted by: Wallace Zou
- Posted on: January 07 2003 17:20 EST
Threaded Messages (6)
- How to present file to user in Web based J2EE application by Dave C on January 08 2003 12:40 EST
- How to present file to user in Web based J2EE application by Wallace Zou on January 08 2003 15:01 EST
- How to present file to user in Web based J2EE application by Wallace Zou on January 11 2003 14:07 EST
- How to present file to user in Web based J2EE application by anecss anecss on February 21 2003 04:19 EST
- How to present file to user in Web based J2EE application by Raj Pat on January 09 2003 00:19 EST
- How to present file to user in Web based J2EE application by Marina Prikaschikova on January 09 2003 00:32 EST
-
How to present file to user in Web based J2EE application[ Go to top ]
- Posted by: Dave C
- Posted on: January 08 2003 12:40 EST
- in response to Wallace Zou
The URL could just be a servlet URL where it sends the file, but sets the mimetype to something like application/octet-stream which would force the user to download the content. -
How to present file to user in Web based J2EE application[ Go to top ]
- Posted by: Wallace Zou
- Posted on: January 08 2003 15:01 EST
- in response to Dave C
Interesting, it's a good idea,
thx! -
How to present file to user in Web based J2EE application[ Go to top ]
- Posted by: Wallace Zou
- Posted on: January 11 2003 14:07 EST
- in response to Dave C
Hi, I find the right place here!
Thanks for your replies!
From help of Dave C, I write a servlet to let user download a text file which is generated dynamically:
...
response.setContentType("application/octet-stream");
PrintWriter pw = response.getWriter();
pw.print(netfiles);
...
It's simple and working. But now if it can prompt a file name to user when it starts that will be perfect, anyone can help! -
How to present file to user in Web based J2EE application[ Go to top ]
- Posted by: anecss anecss
- Posted on: February 21 2003 16:19 EST
- in response to Wallace Zou
response.setHeader("Content-Disposition","attachment; filename=""); -
How to present file to user in Web based J2EE application[ Go to top ]
- Posted by: Raj Pat
- Posted on: January 09 2003 00:19 EST
- in response to Wallace Zou
Just provide link to the related file.If its a text file(or even word document) it will display in the browser itself.If it encounters some different format it will ask the user to download. -
How to present file to user in Web based J2EE application[ Go to top ]
- Posted by: Marina Prikaschikova
- Posted on: January 09 2003 00:32 EST
- in response to Wallace Zou
See for example Content tag from Coldtags suite:
www.servletsuite.com/jsp.htm
you may include files that are located outside of your web application