Win a copy of Machine Learning with R: Expert techniques for predictive modeling this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

writing to a http server using java

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,

This being my first post i apologize if i had broken any of the norms during this post.Please correct if there is anything so that they won't be repeated.

Now to the question,

I have a Wepsphere app server from where i am trying to write a text file to an apache http server using java HTTPConnection class.

I receive the following error when trying to do so ...
"Server returned HTTP response code: 405 for URL ******************* " which i understand is URL forbidden error.

My question is:
1.Is it possible to write directly to a http server from app server.{i was using http PUT}
2. If so , can you please throw some light on what configuration changes on http server should i make for it to work.
3.Is there a better way of doing the same without using HTTPConnection class

Thanks in Advance



 
Sheriff
Posts: 24654
58
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Yes.

2. You shouldn't have to make any changes to the HTTP server. You should change your code so that it sends data in the format required by the HTTP server.

3. You don't have to use Apache's HTTPConnection class. However whether the alternatives are "better" depends on what you mean by that.
 
ramki siva
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

Thanks for the reply.

I have tried the following piece of code without any luck.

When i try this i get a http response code 302.and i don't see any data being written to the file

Is the above code,the standard/correct way of using HTTP PUT?Anything else that needs to be considered for this to work?
 
Paul Clapham
Sheriff
Posts: 24654
58
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

ramki siva wrote:Anything else that needs to be considered for this to work?



You'll need to consider whether the server actually wants a PUT request. Since the error message you got strongly suggested that it rejected the PUT request, perhaps you ought to ask what type of request it wants. There's no point in spending time to get your PUT request exactly right if PUT isn't the right type to use.
 
ramki siva
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

"perhaps you ought to ask what type of request it wants."


How do i find that... Is there any particular entry in http server's httpd.conf files that i should be aware of?
 
Paul Clapham
Sheriff
Posts: 24654
58
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you find that? You ask the person who wanted you to upload that file.
 
Marshal
Posts: 67289
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are thinking that you can do a PUT to any random server and have it accept the request, well, that's not going to happen.

Why don't you tell use what's at the URL you are trying to send the PUT to?
 
Where all the women are strong, all the men are good looking and all the tiny ads are above average:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!