Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTTP 405

 
Ulas Ergin
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
When I type the HTTP messange to the browser I get the response but when i try with Java Code I get the error:

Server returned HTTP response code: 405 for URL: http://www.xyz.com/aspx

The code is like:


what can be the reason?
[ July 21, 2005: Message edited by: Ulas Ergin ]
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
405 is "method not allowed." The browser will use the HTTP "GET" method, but your Java code is using the POST method, because you called getOutputStream(). Since all you're doing is closing it, don't even bother to call that method. URLConnection will then use GET and the code will work.
 
Ulas Ergin
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In fact,the code was incomplete,just to give you an idea.
I post some data to the server and want to read the response back.

I even used conn.setRequestMethod("POST") but it did not help
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulas Ergin:
In fact,the code was incomplete,just to give you an idea.

It seems that the incomplete code gave us the wrong idea. How about giving us a better piece of code with some pseudocode for the missing parts.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic