473,548 Members | 2,780 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

File Upload in J2EE.

dmjpro
2,476 Top Contributor
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=multipa rt/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 9239
dmjpro
2,476 Top Contributor
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=multipa rt/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 Contributor
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 servletinputStr eam.
Sep 13 '07 #3
dmjpro
2,476 Top Contributor
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 servletinputStr eam.
Thanks to share your knowledges with me.
Nice to see this.
First of all tell me what is Boundary?
When I do enctype=multipa rt/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 ServletInputStr eam?

Kind regards,
Dmjpro.
Sep 13 '07 #4
madhoriya22
252 Contributor
Thanks to share your knowledges with me.
Nice to see this.
First of all tell me what is Boundary?
When I do enctype=multipa rt/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 ServletInputStr eam?

Kind regards,
Dmjpro.
Hi,
I think you should use O'reilly's MultipartReques t 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=multipa rt/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 MultipartReques t api it vill not be required. Google for MultipartReques t or file upload using MultipartReques t you vil get a lot of results.
Sep 13 '07 #5
dmjpro
2,476 Top Contributor
Hi,
I think you should use O'reilly's MultipartReques t 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=multipa rt/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 MultipartReques t api it vill not be required. Google for MultipartReques t or file upload using MultipartReques t you vil get a lot of results.

Thanks a lot for your kind information.

Kind regards,
Dmjpro.
Sep 13 '07 #6
madhoriya22
252 Contributor
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
3724
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 word document of 40k wont and so on, in the php.ini a limit of 2mb is set (I haven't changed it, it's how the file originally as, so it isn't my maths...
15
3192
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 html for the form and the basic php scripting but the fine details ie method post etc needs help also at this stage I dont want to involve mysql...
3
2838
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 InputFile control, selects a file, then clicks on the Upload button. The file is saved to a folder on the server and the message label displays the...
1
2749
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" as the directory. When I use any other hard coded directory or even Server.MapPath() the upload function fails and returns the error: "Exception has...
4
4455
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 one of my webform pages which includes a button that pops up a window where you can upload files, if you upload files in this popup window, it...
3
5027
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 around 7MB/s. I'm using a FileUpload control on an .aspx page, and then I'm writing the MyFileUpload.PostedFile.InputStream off to a database. ...
7
3171
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" name="file_1" size=46 /><input type=submit /> so, after adding a few files, the input fields look like this:
2
7636
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 don't have any luck is to do a form validation. This script requires the files: db-file-to-disk.asp and _upload.asp. There is a DESCRIPTION field in...
3
613
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 I can display the Upload Progress.
0
7444
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7711
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. ...
0
7805
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...
0
6039
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...
1
5367
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5085
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3497
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...
1
1054
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
755
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...

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.