Solved

File Upload in Java

Posted on 2002-05-21
16
322 Views
Last Modified: 2010-03-31
I need java code for uploading files to a URL (Servlet).
i.e the code i would write in a java application to connect to a URL and upload my file.

Any sample code would be of great help !
0
Comment
Question by:Jitu
  • 5
  • 3
  • 2
  • +3
16 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 7024018
 There are a number of libraries that do it. Take a look at the jGuru page: http://www.jguru.com/faq/view.jsp?EID=160 it contains useful dicussions and links.

  Hope it helps.
0
 
LVL 19

Expert Comment

by:Jim Cakalic
ID: 7024033
I think you can use the the com.oreilly.servlet package available here:
    http://www.servlets.com/cos/index.html

The javadoc refers to Applet->Servlet communications but I don't see why it couldn't be used for Application->Servlet communications over HTTP.

There is also the HTTPClient package available here:
    http://www.innovation.ch/java/HTTPClient/

Best regards,
Jim Cakalic
0
 
LVL 92

Expert Comment

by:objects
ID: 7025497
Depends on what your servlet expects.

Can you explain how your servlet is expecting the data?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 1

Author Comment

by:Jitu
ID: 7026429
Most of the links posted here point to how to receive the file by a servlet. This is not what i want.

I am looking for Java CLIENT side (application) code that would do a form submit to a URL with a FILE. It would mimic the form submission and send a File.

This link too - http://www.innovation.ch/java/HTTPClient/
does not have the client side File Upload code. It has code for connecting to a URL etc..

I would appreciate if someone can COPY the code here.

Thanks for your Help !!
0
 
LVL 92

Expert Comment

by:objects
ID: 7026447
That's why I asked what format your servlet was expecting the code in? Is it expecting a multipart form post, or something different?
0
 
LVL 1

Author Comment

by:Jitu
ID: 7026611
I have no idea what format the servlet in question is expecting the form post to be, since i only have the URL to the servlet and no other info. in other words - i am not the owner of the servlet and dont have documentation to it at present.

So can u assume the possible formats and tell me what the code would look like.
thanks.
0
 
LVL 92

Expert Comment

by:objects
ID: 7026620
> So can u assume the possible formats

The possibilities are infinite.
You'll need to find what it expects to be able to communicate with it.
What currently posts to it?
0
 

Expert Comment

by:PFMMaas
ID: 7395991
Hmmm.... has anybody actually solved this problem? I'm trying to do the same thing, although I'm writing the servlet myself...

what I would like to do is have an application send a mp3 file to a servlet. Currently I have a working formbase file-upload...

0
 
LVL 35

Expert Comment

by:girionis
ID: 8766931
No comment has been added lately, so it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question is:

- To be deleted and points refunded

Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

girionis
Cleanup Volunteer
0
 
LVL 19

Expert Comment

by:Jim Cakalic
ID: 8767627
OK by me. :-)
Jim
0
 
LVL 1

Author Comment

by:Jitu
ID: 8771088
Ok by me :-),
Pls delete this question.
Thanks
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8819829
PAQ'd and points NOT refunded.  I am willing to refund the points on this as soon as I see Jitu has maintained the other 19 open questions that need finalizing.

To see your options for finalizing those questions see: http://www.experts-exchange.com/help/closing.jsp

I will return in a week to check to see that they have been taken care of.  If they have not been taken care of, I have an obligation to turn the account over to the site administrators.

SpideyMod
Community Support Moderator @Experts Exchange
0
 
LVL 1

Author Comment

by:Jitu
ID: 8825124
SpideyMod > I have now completed  the 'maintenance' for the other open questions... Thanks.
0
 
LVL 1

Author Comment

by:Jitu
ID: 8825129
Is there a way to just see only your 'open' questions, rather seeing all of them....since in this case we have to keep going from one page to another to see the whole list...
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Application launch issue with Apache Tomcat 5 45
Spring Framework HTTPSession management 1 36
Running JavaFX on JDeveloper 12C 1 32
Android development question 2 37
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question