connecting to a servlet

G

gk

i was trying to connect to my servlet from my standalone java
application.

but i got the errors...




java.io.IOException: Server returned HTTP response code: 405 for URL:
http://xvcvbcbbbc....

at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:791)


i found this is a bug.


i used for connection
http://javaalmanac.com/egs/java.net/Post.html

and to get the data in the servelt side..


int contentLength = request.getContentLength();
out.println("<hr>");
out.println("Content length = " +contentLength);
if (contentLength > 0) {
byte[] buffer = new byte[contentLength];
java.io.InputStream inputStream = request.getInputStream();
inputStream.read(buffer);
String content = new String(buffer);
out.println(content.length());
out.println(content);
}
 
R

Roedy Green

java.io.IOException: Server returned HTTP response code: 405 for URL:

I googled that and found:

10.4.6 405 Method Not Allowed

The method specified in the Request-Line is not allowed for the
resource identified by the Request-URI. The response MUST include an
Allow header containing a list of valid methods for the requested
resource.

-----
405 Method Not Allowed The request method is not allowed.
Typically when trying to execute a normal document or display a
script.
------

405 Method not allowed The method specified in the
Request-Line is not allowed for the resource identified by the
Request-URI. The response must include an Allow header containing a
list of valid method's for the requested resource.

-------
405 HTTP_METHOD_NOT_ALLOWED
The method being used to access the file is not allowed.
--------

Basically they are all telling you the right half of your URL is
buggered.


If you ever go to Boston, you have to try the local specialty, scrod,
fresh young cod. I was once on a business trip there and went
wandering the city in search of the delicacy. I don't like asking
directions, but I was getting impatient and hungry, so I finally asked
an old guy selling newspapers, "where can I get scrod?" He replied,
"I've been asked that question many times before, but never by a
Canadian in the pluperfect subjunctive. The above story is apocryphal,
as many of your over 50s can attest.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top