aspose file tools*
The moose likes Java in General and the fly likes HTTP 405 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "HTTP 405" Watch "HTTP 405" New topic
Author

HTTP 405

Ulas Ergin
Ranch Hand

Joined: Oct 10, 2002
Posts: 77
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

Joined: Jul 08, 2003
Posts: 24187
    
  34

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.


[Jess in Action][AskingGoodQuestions]
Ulas Ergin
Ranch Hand

Joined: Oct 10, 2002
Posts: 77
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

Joined: Jul 22, 2000
Posts: 9053
    
  12
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.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTTP 405