tomcat server response code 505

S

SPG

Hi,

I am trying to test an application of ours that opens a URL Connection and
reads the response.
I have set up a tomcat (5.xx) service and I can post to it from IE fine.
As soon as I send exactly the same via JAVA code I get the foolowing error:

java.io.IOException: Server returned HTTP response code: 505 for URL:
http://localhost:8080/TestChartData/chartdata?desc=Steve's Data
Test&shortdesc=test data
at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection
..java:709)
at java.net.URL.openStream(URL.java:960)
at spg.tools.web.chart.SampleConnect.<init>(SampleConnect.java:15)
at spg.tools.web.chart.SampleConnect.main(SampleConnect.java:9)

Server returned HTTP response code: 505 for URL:
http://localhost:8080/TestChartData/chartdata?desc=Steve's Data
Test&shortdesc=test data

Here is amy quick sample code..

try {
URL url = new
URL("http://localhost:8080/TestChartData/chartdata?desc=Steve's Data
Test&shortdesc=test data");
InputStream is = url.openStream(); //FAILS HERE USING TOMCAT
SERVER
int c = 0;
StringBuffer buff = new StringBuffer();
while ( (c = is.read()) > -1) {
buff.append((char)c);
}
System.out.println(buff.toString());
}
catch (Exception ex) {
ex.printStackTrace();
System.out.println(ex.getMessage());
}

Now, I guess I am sending an HTTP request using the wrong protocol version,
as texactly the same request works if just pasted into the IE URL box.

So, What I guess I am asking is how can I find out what version is being
sent using the java app, and how can I configure tomcat to accept this?

BTW, I have a servlet running using the JBuilder dev environment, and when
that is running and I post to that, the URL works fine also!!??

Steve
 
C

Chris Smith

SPG said:
java.io.IOException: Server returned HTTP response code: 505 for URL:
http://localhost:8080/TestChartData/chartdata?desc=Steve's Data
Test&shortdesc=test data

Try properly encoding the URL as:

It may be that IE is doing this for you, but hiding it to be more "user
friendly".

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
S

SPG

Nice fix!
We had different problem in the office with a 400 error, and I suspected
that to be the url encoding, which is why I set up a test here at my home
desk.
When I started getting 505 errors here, I thought I was going mad!

It must be the difference between the way tomcat and IIS handle the url,
either way, I have fixed it thanks to you!

Cheers mate,

Steve
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top