• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

uploading a file using jsp

 
vidula kulkarni
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
how can i upload a file in jsp?is there a way to call a servlet from a jsp.
thanks
 
Asif Anis
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
SRINI VASAN
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
U can do that by using Multipart. Please browse through URLhttp://www.jspsmart.com/liblocal/docs/en/articles/upload_en.htm for details. Mail me if have any more doubts.
regards,
srini
 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dear
better use jspSmatUpload
search fr it on google...
good luck
 
sea yin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%@ 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>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic