Solved

Telnet works but my java code does not!

Posted on 2008-10-29
6
265 Views
Last Modified: 2013-12-29
Hi, I can get a response with Telnet, sending this,

GET /?hl=en_US&src=14&s=V84LsjuD5KnXVZRT9zOwV4j0trE
Host: 127.0.0.1:38847


and I get this

Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
HTTP/1.1 200 OK
Content-Type: text/html
Connection: close

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
.....

but my java code imitating it does not

        String urlStr = "http://127.0.0.1:38847/?hl=en_US&src=14&s=V84LsjuD5KnXVZRT9zOwV4j0trE";
        try {
            URL url = new URL(urlStr);            
            HttpURLConnection con = (HttpURLConnection) url.openConnection();
            con.setRequestProperty("Host", "127.0.0.1:38847");  
            con.connect();
            System.out.println(con.getResponseCode());
....
0
Comment
Question by:kerzner
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 5

Expert Comment

by:muktajindal
ID: 22839368
What is the error that the java code is throwing ?
0
 
LVL 1

Author Comment

by:kerzner
ID: 22845555
stream breaks unexpectedly and -1 is the number of bytes returned
0
 
LVL 1

Author Comment

by:kerzner
ID: 22873657
I am running telnet from java
it works

now my problem is that is works from my java program, but not when this same code is inside jboss
0
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
LVL 5

Accepted Solution

by:
muktajindal earned 500 total points
ID: 22873660
How did you resolve the Java error ?
What is the error with Jboss now ??
0
 
LVL 1

Author Comment

by:kerzner
ID: 22873678
I resolved the java errors by running telnet as process, giving it inputs and reading it outputs

from jboss, I get no output :)
0
 
LVL 1

Author Closing Comment

by:kerzner
ID: 31511549
needed to run JBoss in my account, not root
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Weekend adv creator 3 64
Java string replace 11 64
jsp insert to database example 2 65
Hibernate Inheritance Strategy for Abstract Base class and two concrete classes 3 20
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question