aspose file tools*
The moose likes Java in General and the fly likes Https post method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Https post method" Watch "Https post method" New topic
Author

Https post method

Atul Darne
Ranch Hand

Joined: Jul 05, 2009
Posts: 118

i have setup a MSIIS server on windows XP, iam able to connect to the server
by the following program




even iam able to reterive the contents of a index.html that i have made and placed in inetpub/wwwroot

iam able to browse the directory

i need to upload the documents to that directory

please suggest some code for it



Regards, Atul.
I came to this world on a Learner's License
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9313
    
  17

Nothing to do with SCJP, moving...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

This is possible with the standard libraries, but is a lot easier if you use an additional library designed for HTTP communication. For example the Apache HTTPClient (Find It Here) is a common one. Follow the link for downloads, tutorials, and code samples.


Steve
Atul Darne
Ranch Hand

Joined: Jul 05, 2009
Posts: 118

Steve Luke wrote:This is possible with the standard libraries, but is a lot easier if you use an additional library designed for HTTP communication. For example the Apache HTTPClient (Find It Here) is a common one. Follow the link for downloads, tutorials, and code samples.



thanks steve. i got the idea, but what about if i need to implement https ?
Atul Darne
Ranch Hand

Joined: Jul 05, 2009
Posts: 118

iam able to browse the directory through firefox or internet explorer, but same thing i need to do with a simple java https program.
after access i.e getting the directory, i need to add and retrieve documents from directory.
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Atul Darne wrote:thanks steve. i got the idea, but what about if i need to implement https ?

The Apache HTTP client fully implements https/ssl/tls. You really do not want to do this yourself. While its not all that hard to get https to work in simple cases, getting it 100% right and secure is very, very hard.

One should never implement code when there is a well maintained library that does what you need.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18989
    
  40

Pat Farrell wrote:
The Apache HTTP client fully implements https/ssl/tls. You really do not want to do this yourself. While its not all that hard to get https to work in simple cases, getting it 100% right and secure is very, very hard.

One should never implement code when there is a well maintained library that does what you need.



On the other hand (as a counterpoint to every apache httpclient fan here), I have used the built-in URL class in some very complex scenarios, for a commercial product, for all types of connections (including secure connections) .... and it isn't all that hard.

Henry

Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Atul Darne
Ranch Hand

Joined: Jul 05, 2009
Posts: 118

i have tried couple of things, but still stucked up.
iam not able to upload the data files[or whatever the upload file is] to the http server root.

is there any way to post the files to the server
please assist and help.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18989
    
  40

Atul Darne wrote:i have tried couple of things, but still stucked up.
iam not able to upload the data files[or whatever the upload file is] to the http server root.

is there any way to post the files to the server
please assist and help.


The POST method doesn't mean the ability to upload files to the server. The POST method is a method of passing parameters to the server. Think of it as simply a protocol.

Henry
Atul Darne
Ranch Hand

Joined: Jul 05, 2009
Posts: 118

thanks Henry , but if i need to upload some data on to server directory, how should i proceed. please suggest some code snap. Iam using MSIIS 5.0 from windows XP and even apache tomcat as http servers.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Do you have code on the Server side which accepts an POST request and knows how to process the contents as a File to store?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Whatever code you write on the client side has to have something to talk to on the server side. I'm sure Microsoft has some extensions of some kind to allow web content to be uploaded -- maybe part of "FrontPage?" You won't learn much about that here, though. Your best bet would be searching Microsoft's knowledge base, or asking in a Microsoft IIS forum of some kind.

After you know about how the server side stuff works, if you need help talking to it from Java, then by all means, c'mon back here.


[Jess in Action][AskingGoodQuestions]
Atul Darne
Ranch Hand

Joined: Jul 05, 2009
Posts: 118

Steve Luke wrote:Do you have code on the Server side which accepts an POST request and knows how to process the contents as a File to store?


hi Steve,

i have some ending to the http url, provided by my friend. it might accept the POST request, if i send something to it.

And even i would like to know it in detail, if i myself configure it on my machine, it would add up to my knowledge. about processing the contents and store it.

thanks for your valuable reply in advance
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Atul Darne wrote:
Steve Luke wrote:Do you have code on the Server side which accepts an POST request and knows how to process the contents as a File to store?


hi Steve,

i have some ending to the http url, provided by my friend. it might accept the POST request, if i send something to it.

And even i would like to know it in detail, if i myself configure it on my machine, it would add up to my knowledge. about processing the contents and store it.

thanks for your valuable reply in advance


I don't really understand this post. But I think you have to work on knowing what technology you have available to you, and what you have on the server. You need to make sure the server uses HTTPS. You need to make sure there the requested resource knows how to process a POST request. You need to know the requested resource expects a multipart/form-data content and can process the data to store as a file.

If none of that makes sense to you then you need more research on the server side technology you are using until you can make sense of it, and be sure that the server side is working. If you are using IIS, then I can't help you. If you want to make it using Tomcat, then you can start here with these links:
Tomcat Documentation: Especially sections 1-3 for setting up and getting started
The JEE Sevlets tutorial: Pretty much the entire thing. If you get through it and understand it, you should be able to write your own servlet for receiving the POST request and processing the file.
CodeRanch Servlets Forum: For specific help in writing the Servlet side of the upload.
CodeRanch Tomcat Forum: For specific help in working with Tomcat.
Apache Commons FileUpload: A tool to help with the FileUpload functionality on the server side. This is not a shortcut for learning Servlets. Once you can write your own 'file upload servlet' then this utility may make it a bit easier to manage (not necessary for basic file uploads though...)
Atul Darne
Ranch Hand

Joined: Jul 05, 2009
Posts: 118

thanks Steve !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Https post method