?
Solved

Telnet works but my java code does not!

Posted on 2008-10-29
6
Medium Priority
?
273 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 5

Accepted Solution

by:
muktajindal earned 2000 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

Technology Partners: 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

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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses
Course of the Month10 days, 13 hours left to enroll

765 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