• 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

writing to a http server using java

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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



 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do you find that? You ask the person who wanted you to upload that file.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic