This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Servlets and the fly likes uploading a file using jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Servlets
Bookmark "uploading a file using jsp" Watch "uploading a file using jsp" New topic

uploading a file using jsp

vidula kulkarni

Joined: May 24, 2001
Posts: 18
how can i upload a file in jsp?is there a way to call a servlet from a jsp.
Asif Anis

Joined: Mar 02, 2001
Posts: 19
where do u want to upload the file? if u r uploading a file in the datdabase then which database because i've recently uploaded files in datdbase oracle 8i , and i used the blob data type for that
Ranch Hand

Joined: Aug 29, 2000
Posts: 48
U can do that by using Multipart. Please browse through URL for details. Mail me if have any more doubts.

You can contact me in
Malhar Barai
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
better use jspSmatUpload
search fr it on google...
good luck

Malhar Barai
SOA & Java Book
sea yin

Joined: Sep 09, 2001
Posts: 5
<%@ page language="java" import="com.jspsmart.upload.*"%> <jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" /> <HTML> <BODY BGCOLOR="white"> <H1>jspSmartUpload : Sample 2</H1> <HR> <% // Variables int count=0; // Initialization mySmartUpload.initialize(pageContext); // Upload mySmartUpload.upload(); // Select each file for (int i=0;i<mySmartUpload.getFiles().getCount();i++){ // Retreive the current file com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(i); // Save it only if this file exists if (!myFile.isMissing()) { // Save the files with its original names in a virtual path of the web server myFile.saveAs("/upload/" + myFile.getFileName()); // myFile.saveAs("/upload/" + myFile.getFileName(), mySmartUpload.SAVE_VIRTUAL); // sample with a physical path // myFile.saveAs("c:\\temp\\" + myFile.getFileName(), mySmartUpload.SAVE_PHYSICAL); // Display the properties of the current file out.println("FieldName = " + myFile.getFieldName() + "<BR>"); out.println("Size = " + myFile.getSize() + "<BR>"); out.println("FileName = " + myFile.getFileName() + "<BR>"); out.println("FileExt = " + myFile.getFileExt() + "<BR>"); out.println("FilePathName = " + myFile.getFilePathName() + "<BR>"); out.println("ContentType = " + myFile.getContentType() + "<BR>"); out.println("ContentDisp = " + myFile.getContentDisp() + "<BR>"); out.println("TypeMIME = " + myFile.getTypeMIME() + "<BR>"); out.println("SubTypeMIME = " + myFile.getSubTypeMIME() + "<BR>"); count ++; } } // Display the number of files which could be uploaded out.println("<BR>" + mySmartUpload.getFiles().getCount() + " files could be uploaded.<BR>"); // Display the number of files uploaded out.println(count + " file(s) uploaded."); %> </BODY> </HTML>
I agree. Here's the link:
subject: uploading a file using jsp
It's not a secret anymore!