Data echo problen on localhost,return null instead of data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • coolbyte
    New Member
    • Apr 2009
    • 3

    Data echo problen on localhost,return null instead of data

    i m trying to echo data, send to server back back on client on the local system using localhost but it returns null..i am using apache tomcat 6.0 as web server.please suggest some way to do this or suggest ,if any, problem with the code?
    using 8080 as port no. bcoz tomcat listens on it

    code is
    Code:
    try {
                echoSocket = new Socket("localhost",8080);
                out = new PrintWriter(echoSocket.getOutputStream(), true);
    
                in = new BufferedReader(new InputStreamReader(
                                            echoSocket.getInputStream()));
            } catch (UnknownHostException e) {
                System.err.println("Don't know about host: taranis.");
                System.exit(1);
            } catch (IOException e) {
                System.err.println("Couldn't get I/O for "
                                   + "the connection to: taranis.");
                System.exit(1);
            }
    
    	BufferedReader stdIn = new BufferedReader(
                                       new InputStreamReader(System.in));
    	String userInput;
    
    	while ((userInput = stdIn.readLine()) != null) {
    	    out.println(userInput);
    	     System.out.println("echo: " + in.readLine());
    	}
    Last edited by Nepomuk; Apr 22 '09, 01:30 PM. Reason: Please use [code] tags
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    Right now, I can't see any error there. However, your Server may be doing something wrong - could we see some relevant code there please?

    Greetings,
    Nepomuk

    Comment

    • coolbyte
      New Member
      • Apr 2009
      • 3

      #3
      actually, i haven't modified anything with the server, i made a fresh installation of apache-tomcat 6.0 on window XP for providing server support and 8080 is the default port for listening.Is a servlet at server-end correct way to solve the problem??..when i made a program for listening to this request which acts as a server for this on the same machine..it works but i am trying to route the processing through this server...Please suggest some way

      Comment

      • Nepomuk
        Recognized Expert Specialist
        • Aug 2007
        • 3111

        #4
        Tomcat will run servlets for you but not do much itself when it comes to reacting to signals from outside (e.g. the internet). If you want it to echo something back to you, you'll have to write an echo server which tomcat can run.

        Greetings,
        Nepomuk

        Comment

        • coolbyte
          New Member
          • Apr 2009
          • 3

          #5
          Thanks a lot for your efforts..i think i need to work some more on Tomcat server

          Comment

          Working...