473,654 Members | 3,251 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MultipartReques t

oll3i
679 Contributor
i try to upload a file using MultipartReques t
i want to get the name of the file uploaded with html form
and display it on jsp page (just for now to see if it works)
in server.log i see Error creating file: java.io.IOExcep tion: Corrupt form data: premature ending
code i use and it doesnt work
Expand|Select|Wrap|Line Numbers
  1.  try
  2. {
  3. MultipartRequest mrequest = new MultipartRequest(request, filesSavePath);
  4. Enumeration files = mrequest.getFileNames();
  5.  
  6. for (int i = 1; files.hasMoreElements( );i++)
  7.     p= mrequest.getFilesystemName((String) files.nextElement( ));
  8.  
  9.  
  10.  
  11. }
  12. catch(Exception ex)
  13. {
  14. System.out.println("Error creating file: " + ex );
  15. }
  16.  
thank You
Jan 11 '09 #1
3 3586
r035198x
13,262 MVP
What's the code for your form?
Jan 12 '09 #2
oll3i
679 Contributor
Expand|Select|Wrap|Line Numbers
  1.     <form action="faces/result.jsp" method="POST" enctype="multipart/form-data">
  2.       <input type="file" name="cv" value="" width="50" />
  3.       <input type="submit" value="Wyślij" />
  4.       </form>
  5.  
Jan 12 '09 #3
r035198x
13,262 MVP
Why are you submitting to a JSP instead of to a servlet? Read the manual provided at apache's commons-fileupload site to see how it's supposed to be done.
Jan 13 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
4061
by: cv | last post by:
Hello All, I have used MultipartRequest like the following to upload images. MultipartRequest multi = new MultipartRequest(request, "../webapps/coreprogram/dealerlogos", 1024 * 1024); It works fine. But When a user accesses through Internet, this does not work.
6
6946
by: jajoo | last post by:
Hi, I have a problem with using *.jar files with Tomcat 5.0.16. I place the jar in the lib directory of the application but server throws Exception. java.lang.NoClassDefFoundError: javax/servlet/ServletRequest com.oreilly.servlet.MultipartRequest.(MultipartRequest.java:222) com.oreilly.servlet.MultipartRequest.(MultipartRequest.java:109) com.oreilly.servlet.MultipartRequest.(MultipartRequest.java:89)...
1
7121
by: jajoo | last post by:
Hi everyone, I am trying to send files with multipart/form-date. Everything is ok with the send. But when I am receiving the files I should specify a directory where the files to be saved. The problem is that Tomcat saves the files into %CATALINA_HOME%/bin directory. I am wondering why? Why not into my application directory? The application directory is %CATALINA_HOME%/webapps/picture. As a parameter of directory I am giving "." – which...
1
1942
by: John C. Wallace | last post by:
I have written a Java application that will upload files and fields to a MultipartRequest servlet. However, I now need to do the same in C++. Although very similar, I do not know how to go about handling the HTTP io streams. Once I know how to transfer information via io streams over the internet I think I can do the rest on my own. Any help would be great. John C. Wallace
6
9251
dmjpro
by: dmjpro | last post by:
Have a look at my HTML Code and my Java code. I m trying to see the total contents when a form is submitted with enctype=multipart/form-data. <html> <head> <title>Simple File Upload Test</title> </head> <body> <form name = "test_form" method ="POST" enctype="multipart/form-data" action = "../jsp/FileUpload.jsp">
2
5011
by: praveenkumarvpk | last post by:
Hi friends Please help me! Following is my servlet-code import java.util.Enumeration; import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import com.oreilly.servlet.MultipartRequest;
1
5585
by: shyaminf | last post by:
hi everybody! iam facing a problem with the transfer of file using servlet programming. i have a code for uploading a file. but i'm unable to execute it using tomcat5.5 server. kindly help me how to execute it using tomcat server5.5. the code is as follows. if you have any other coding regarding this, please send me.it's urgent. import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*;
0
1285
by: akaley | last post by:
Hi All, Iam using MultiPartRequest class(cos.jar) for Reading the file comtent from Client Machine. My coding is working without any problem in My local system.But in testing server it causes some problem.My local system is Window o/s. Testing Server is UNIX based system.This is the problem iam facing while loading the files: The files with " XXXXX---SPECReport.xls" names are causing problem.
1
1826
by: akaley | last post by:
Hi All, My system file upload functionality..iam storing file content in DataBase by using Blob data type. But my problem is MultipartRequest is automaticlly store the file in tomcat/bin directory.. Iam using following code; MultipartRequest multi = new MultipartRequest(request, ".",100 * 1024 * 1024); it's storing the file in "Default directory".i don't want that one,because iam storing file in data base itself.
0
8376
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8489
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8594
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7307
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1596
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.