473,320 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

File Upload in J2EE.

dmjpro
2,476 2GB
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.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.   <head>
  3.     <title>Simple File Upload Test</title>
  4.   </head>
  5.   <body>
  6.       <form name = "test_form" method ="POST" enctype="multipart/form-data" action = "../jsp/FileUpload.jsp">
  7.           <input type="file">
  8.           <input type="submit">
  9.       </form>
  10.   </body>
  11. </html>
  12.  
Expand|Select|Wrap|Line Numbers
  1. ServletInputStream in = request.getInputStream();
  2. //Here request is the reference of HttpServletRequest.
  3. byte b[] = new byte[255];
  4. int len;
  5. while((len = in.read(b))!=-1) out.print(new String(b,0,len));
  6.  
My O/P is showing something like this..............!
Expand|Select|Wrap|Line Numbers
  1. -----------------------------5238189273319--
Can't I get the total Content sent by the Browser?

Please help.

Kind regards,
Dmjpro.
Sep 13 '07 #1
6 9224
dmjpro
2,476 2GB
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.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.   <head>
  3.     <title>Simple File Upload Test</title>
  4.   </head>
  5.   <body>
  6.       <form name = "test_form" method ="POST" enctype="multipart/form-data" action = "../jsp/FileUpload.jsp">
  7.           <input type="file">
  8.           <input type="submit">
  9.       </form>
  10.   </body>
  11. </html>
  12.  
Expand|Select|Wrap|Line Numbers
  1. ServletInputStream in = request.getInputStream();
  2. //Here request is the reference of HttpServletRequest.
  3. byte b[] = new byte[255];
  4. int len;
  5. while((len = in.read(b))!=-1) out.print(new String(b,0,len));
  6.  
My O/P is showing something like this..............!
Expand|Select|Wrap|Line Numbers
  1. -----------------------------5238189273319--
Can't I get the total Content sent by the Browser?

Please help.

Kind regards,
Dmjpro.
Somebody please help!

Kind regards,
Dmjpro.
Sep 13 '07 #2
madhoriya22
252 100+
Somebody please help!

Kind regards,
Dmjpro.
Hi,
I output is printing the boundary value.

Are you sure by doing this you are getting the file from the client. How you are binding that file into servletinputStream.
Sep 13 '07 #3
dmjpro
2,476 2GB
Hi,
I output is printing the boundary value.

Are you sure by doing this you are getting the file from the client. How you are binding that file into servletinputStream.
Thanks to share your knowledges with me.
Nice to see this.
First of all tell me what is Boundary?
When I do enctype=multipart/form-data in a form Tag then in which format the data comes into the server?
And where should I do binding the file into ServletInputStream?

Kind regards,
Dmjpro.
Sep 13 '07 #4
madhoriya22
252 100+
Thanks to share your knowledges with me.
Nice to see this.
First of all tell me what is Boundary?
When I do enctype=multipart/form-data in a form Tag then in which format the data comes into the server?
And where should I do binding the file into ServletInputStream?

Kind regards,
Dmjpro.
Hi,
I think you should use O'reilly's MultipartRequest api to upload the file. what you need to do is ........ download the jar file from here http://www.servlets.com/cos/ Here you find the api for file upload and by a little searching you find jar also. You can use apache's JCommon for file download also.

Boundary is a value which is attached with headers while sending file from client(I think so).

When you do enctype=multipart/form-data your data comes in multipart format but for that your html page should support RFC encoding.
Binding of file should be done on server side. But I really dont know how you should do that. But if you vil use MultipartRequest api it vill not be required. Google for MultipartRequest or file upload using MultipartRequest you vil get a lot of results.
Sep 13 '07 #5
dmjpro
2,476 2GB
Hi,
I think you should use O'reilly's MultipartRequest api to upload the file. what you need to do is ........ download the jar file from here http://www.servlets.com/cos/ Here you find the api for file upload and by a little searching you find jar also. You can use apache's JCommon for file download also.

Boundary is a value which is attached with headers while sending file from client(I think so).

When you do enctype=multipart/form-data your data comes in multipart format but for that your html page should support RFC encoding.
Binding of file should be done on server side. But I really dont know how you should do that. But if you vil use MultipartRequest api it vill not be required. Google for MultipartRequest or file upload using MultipartRequest you vil get a lot of results.

Thanks a lot for your kind information.

Kind regards,
Dmjpro.
Sep 13 '07 #6
madhoriya22
252 100+
Thanks a lot for your kind information.

Kind regards,
Dmjpro.
Hi,
Binding of file should be done at client side not at server side. Sorry :(
Sep 13 '07 #7

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

Similar topics

1
by: Amy Kimber | last post by:
Hello all, ok, I have a file upload secton to my site, two pages, one with a form and one that does the uploading.... some files upload fine, other don't an exe of 300k will upload, but a...
15
by: Simon | last post by:
I would like to create a very basic file upload add image form to add to my web site and to keep them in a "tmp" directory within my web hosting file manager once uploaded. I understand the basic...
3
by: Bijoy Naick | last post by:
I've written a simple file upload user control in VB .NET. It comprises of an InputFile HTML Server Control, an Upload button and a message label. User clicks on the Browse button of the...
1
by: BW | last post by:
I am creating an upload/download function for an extranet site. Files will be uploaded to directory based upon the users login and associated project. The function works as long as I use "c:\Temp"...
4
by: Matt Jensen | last post by:
Howdy I've got a rather strange issue occuring. I used forms based .NET authentication, although I'm also setting some session variables when people login. However, I've found when people use...
3
by: Mike Kelly | last post by:
Hi. I've built a page using standard ASP.NET 2.0 features and when I upload a large file (>20MB) to our intranet server, I get a paltry 100KB/s on our 100Mb/s LAN. Simply copying the file, I get...
7
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file"...
2
by: hotflash | last post by:
Hi All, I found the best pure ASP code to upload a file to either server and/or MS Access Database. It works fine for me however, there is one thing that I don't like and have tried to fix but...
3
by: shapper | last post by:
Hello, I need to upload a file. Can I only do this with the File Upload control? I also need the following: - Send upload info, upload percentage, continuously to a JavaScript function so...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.