Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to send the content of an XML file over socket

843790Nov 24 2006 — edited Nov 24 2006
Hi

I am writing a code where the socket server will read an XML file and send the content to the server. Here is the code snippet -

Client -
char[] src=new char[5000];
Socket client=new Socket("localhost",8888);
PrintStream out=new PrintStream(client.getOutputStream());
BufferedReader in=new BufferedReader(new InputStreamReader(client.getInputStream()));
FileInputStream fstream = new FileInputStream ("test.xml") ;
BufferedReader bufferIn = new BufferedReader ( new InputStreamReader(fstream));
bufferIn.read(src,0,src.length);
out.println(src);
client.close();

Server -
char[] temp = new char[5000];
BufferedReader in = new BufferedReader (new InputStreamReader(client.getInputStream()));
PrintStream out = new PrintStream (client.getOutputStream());

in.read(temp,0,temp.length);
String inputXML = new String(temp);

writeLog(inputXML);
XMLReader parser = XMLReaderFactory.createXMLReader();
org.xml.sax.ContentHandler handler = new derivedClass();
parser.setContentHandler(handler);
parser.parse(inputXML);

The problem is that writeLog() gives the correct output, but parser says "no protocol" in the inputXML.

Can you please figure out what is happening ?

Thanking you in advance ...
Nirmalya
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 22 2006
Added on Nov 24 2006
1 comment
302 views