• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Https post method

 
Ranch Hand
Posts: 119
Oracle Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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


 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing to do with SCJP, moving...
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Atul Darne
Ranch Hand
Posts: 119
Oracle Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 119
Oracle Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Atul Darne
Ranch Hand
Posts: 119
Oracle Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 119
Oracle Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Atul Darne
Ranch Hand
Posts: 119
Oracle Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 119
Oracle Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Steve !
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic