•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 374,616 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,255 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 2180 | Replies: 8
![]() |
You want to download Files from the server using jsp page ? If You want a file browser in jsp than you should search on google for Browser.jsp created by Taylor Bastien, David Levine, David Cowan
It has all the thing you require. I cant paste its code here because it is too long search for browser.jsp + its authors name u will find it. I hope this have solved your query partially other pop up window stuff yet there.
It has all the thing you require. I cant paste its code here because it is too long search for browser.jsp + its authors name u will find it. I hope this have solved your query partially other pop up window stuff yet there.
Ideas are the building blocks of Ideas
Jason Zebehazy
Jason Zebehazy
JSP Syntax (Toggle Plain Text)
<!-- upload.jsp --> <%@ page import="java.io.*" %> <% String contentType = request.getContentType(); System.out.println("Content type is :: " +contentType); if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) { DataInputStream in = new DataInputStream(request.getInputStream()); int formDataLength = request.getContentLength(); byte dataBytes[] = new byte[formDataLength]; int byteRead = 0; int totalBytesRead = 0; while (totalBytesRead < formDataLength) { byteRead = in.read(dataBytes, totalBytesRead, formDataLength); totalBytesRead += byteRead; } String file = new String(dataBytes); String saveFile = file.substring(file.indexOf("filename=\"") + 10); //out.print("FileName:" + saveFile.toString()); saveFile = saveFile.substring(0, saveFile.indexOf("\n")); //out.print("FileName:" + saveFile.toString()); saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1,saveFile.indexOf("\"")); //out.print("FileName:" + saveFile.toString()); //out.print(dataBytes); int lastIndex = contentType.lastIndexOf("="); String boundary = contentType.substring(lastIndex + 1,contentType.length()); //out.println(boundary); int pos; pos = file.indexOf("filename=\""); pos = file.indexOf("\n", pos) + 1; pos = file.indexOf("\n", pos) + 1; pos = file.indexOf("\n", pos) + 1; int boundaryLocation = file.indexOf(boundary, pos) - 4; int startPos = ((file.substring(0, pos)).getBytes()).length; int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length; saveFile = "D:\\java\tomcat5\\webapps\\ROOT\\images\\" + saveFile; FileOutputStream fileOut = new FileOutputStream(saveFile); //fileOut.write(dataBytes); fileOut.write(dataBytes, startPos, (endPos - startPos)); fileOut.flush(); fileOut.close(); out.println("File saved as " +saveFile); } %>
Html file for this is
html Syntax (Toggle Plain Text)
<html> <head></head> <body background="bgcircle.gif"> <form method="post" action="products.jsp" name="upform" enctype="multipart/form-data"> <table width="60%" border="0" cellspacing="1" cellpadding="1" align="center" class="style1"> <tr> <td align="left"> <b><font color="white">Select a file to upload :</b></td> </tr> <tr> <td align="left"> <input type="file" name="uploadfile" size="50"> </td> </tr> <tr> <td align="left"> <input type="hidden" name="todo" value="upload"> <input type="submit" name="Submit" value="Upload"> <input type="reset" name="Reset" value="Cancel"> </td> </tr> </table> </form> </body> </html>
Last edited by peter_budo : May 15th, 2008 at 4:23 am. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Nov 2004
Location: Netherlands
Posts: 5,588
Reputation:
Rep Power: 18
Solved Threads: 187
•
•
Join Date: Nov 2004
Location: Netherlands
Posts: 5,588
Reputation:
Rep Power: 18
Solved Threads: 187
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 1,921
Reputation:
Rep Power: 9
Solved Threads: 217
•
•
•
•
hi can u tell me how to provide connectiviity between Servlet and database
Sun's tutorials on Java spell it all for you
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JSP Marketplace
Similar Threads
- struts tutorials (Java)
- messed up desktop (Viruses, Spyware and other Nasties)
- file download problem (Perl)
- cant acess some websites and some programs wont connect to the net. (Viruses, Spyware and other Nasties)
- Please help. I HAVE to get rid of Rundll.exe :( (Viruses, Spyware and other Nasties)
- HELP please daughters HJT (Viruses, Spyware and other Nasties)
- It Constantly Keeps Re-booting Itself. Plz Help (Viruses, Spyware and other Nasties)
- please help!!!!!!! HJT scan attached...! (Viruses, Spyware and other Nasties)
- Forwarding Hotmail with attachments (Windows NT / 2000 / XP / 2003)
- Cleaning up duaghter's pc - slow and buggy (Viruses, Spyware and other Nasties)
Other Threads in the JSP Forum
- Previous Thread: sending email from jsp
- Next Thread: jsp and mysql



Linear Mode