473,414 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

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
Expand|Select|Wrap|Line Numbers
  1. try {
  2.             echoSocket = new Socket("localhost",8080);
  3.             out = new PrintWriter(echoSocket.getOutputStream(), true);
  4.  
  5.             in = new BufferedReader(new InputStreamReader(
  6.                                         echoSocket.getInputStream()));
  7.         } catch (UnknownHostException e) {
  8.             System.err.println("Don't know about host: taranis.");
  9.             System.exit(1);
  10.         } catch (IOException e) {
  11.             System.err.println("Couldn't get I/O for "
  12.                                + "the connection to: taranis.");
  13.             System.exit(1);
  14.         }
  15.  
  16.     BufferedReader stdIn = new BufferedReader(
  17.                                    new InputStreamReader(System.in));
  18.     String userInput;
  19.  
  20.     while ((userInput = stdIn.readLine()) != null) {
  21.         out.println(userInput);
  22.          System.out.println("echo: " + in.readLine());
  23.     }
Apr 22 '09 #1
4 1481
Nepomuk
3,112 Expert 2GB
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
Apr 22 '09 #2
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
Apr 23 '09 #3
Nepomuk
3,112 Expert 2GB
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
Apr 23 '09 #4
Thanks a lot for your efforts..i think i need to work some more on Tomcat server
Apr 24 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Antoni | last post by:
Hello, I wondered if anyone could offer some guidance, I trying to write a php script to connect to a database, and display the records in a table. I found the code here in a php4 text, and...
3
by: Matt D | last post by:
In my web service project I've imported an assembly (that I also have the source to) that contains structs that are serializable. I've created some web service methods that return and take as...
3
by: Me Alone | last post by:
Hello: I am trying to edit some C code I found in "The definitive guide to using, programming, and administering MySQL" by Paul DuBois. This C client program connects and then segfaults when...
1
by: sujithegr8 | last post by:
HIii... Its me sujith i've done something with AJAX. but for the rest i need someo ones help.. i've done half the work. there are two tables. "ajax1" and "ajax2" (check db.sql)
2
by: basestring | last post by:
Hi I am busy now for many hours without luck I have a database and when I use PHP to add date to it, it works only one time when i want to add the next data, It doesn't work. but i don't get any...
2
by: ph33red | last post by:
Hi, I'm having a problem getting my code to pull the appropriate information when I call for it via URL. (example: http://..../.php?id=2). For some reason I can't get it to pull the information for...
3
by: planey | last post by:
Hi, I was reading topic about setters and getters (http://www.thescripts.com/forum/thread631267.html) and wanted to ask, how they should be used? I have noticed that a general data validators suck,...
2
by: nse111 | last post by:
I hv a form in my php file to accept some data from the user. Then as shown below I capture the data using PHP. the data is getting captured in the variables no prob with that. but the data...
2
by: macdalor | last post by:
I'm trying to add a guestbook to my website and got these scripts from the net (http://www.phpeasystep.com/workshopview.php?id=15) but only 1d and date&time are being recorded in the sql db; name,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.