File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Uploading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Uploading" Watch "Uploading" New topic
Author

Uploading

Richard West
Ranch Hand

Joined: Jan 07, 2005
Posts: 127
Hi everyone,

I have a rather confusing question but please bear with me for a while.

You see i am trying to upload a file to a certain website called http://www.doubleZ.com.

I am using java's HttpUrlConnection class. Connecting to the website is okay and i am also getting its outputstream so i can upload the html page to the above site.

The thing is that the html page that i want to upload must be placed at this address http://www.doubleZ.com/roll/wt.html

Now my question is how to i create the folders to upload the html file to the address http://www.doubleZ.com/roll/wt.html
when the space that i have is just assigned with this address
http://www.doubleZ.com, so basically what i need is a way to create the folder named roll by using Java from the client side before i can upload the html file.

I hope i have not confused anyone

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Moved to the Servlets forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

so basically what i need is a way to create the folder named roll by using Java from the client side before i can upload the html file.


There is no Java on the client side (unless you count Applets).

Any Java that gets executed, either as a servlet or as a JSP, executes on the server.

As such, creating a file or folder on the server file system is a simple matter of Java file I/O for any area in which you have appropriate permissions.

Does this change your question at all?
[ July 27, 2006: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

P.S. If you need to be able to detect where your app is located on the server's file system, check out the ServletContext.getRealPath() method (which works fine unless you are running the app out of an unexpanded war file).
Richard West
Ranch Hand

Joined: Jan 07, 2005
Posts: 127
Hi everyone,

Originally posted by Bear Bibeault:
As such, creating a file or folder on the server file system is a simple matter of Java file I/O for any area in which you have appropriate permissions.


For me assume that i have a html file on my disk called wt.html,
now what i am trying to do is create a HTTP uploader so that i can upload my wt.html file to the location at address http://www.doubleZ.com/roll/wt.html

No before i can upload to that location i need to create the directory roll on the server because all i have is this address http://www.doubleZ.com

Basically my question is that once i have authenticated myself into this address http://www.doubleZ.com how do i create the directory roll and create the file called wt.html on the server all from my side.

Is there a way this can be achieved?

Yours Sincerely

Richard West
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Originally posted by Richard West:
how do i create the directory roll and create the file called wt.html on the server all from my side.


What is "my side"? I'll assume you mean the client.

If so, you can't merely from HTML or Javascript. You'll either need to write a servlet to perform such actions on your behalf, or use an ftp client, or ssh into the server to create the folder from the command line.
 
jQuery in Action, 2nd edition
 
subject: Uploading
 
Similar Threads
GWT: Ajax file upload?
how to Transfer file from client browser to server?
Using PC as server
Multiple .War files on Tomcat container
Text Or Binary