Solved

Telnet works but my java code does not!

Posted on 2008-10-29
6
269 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

728 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