Streaming data in java

My applet needs to stream data from a server.

Server is .NET/C#

I have two implementations but both are not the exact thing which i want.

So if anyone have any better ideas please do give suggestions.

1) My server application will write to a hidden variable.

My client java program representing the applet have a thread which checksthe value of this variable and once the variable gets data use that to do the task.

The task in my scenario is printing.

2) My server will send some text in a specified format using the Response.Write() function

My java program reads it using

DataInputStream in =new DataInputStream(urlconnection.getInputStream());

Now the problem with the second implementation is response.write() displays the content on the page also which makes it visible to all.Also in addition to the text written using Reponse.Write() the input stream returns all the html tags also.

So can anyone tell me a better way to stream data in java.

I know both these implementations are not implementing the concept of streaming.

Thank You.

[1162 byte] By [santhoshymaa] at [2007-10-3 2:53:46]
# 1
Isn't there anyone who can give some comments on this?
santhoshymaa at 2007-7-14 20:42:49 > top of Java-index,Java Essentials,Java Programming...
# 2
> Isn't there anyone who can give some comments on> this?Excuse me... are you paying for this service? No? Then 32 minutes is not a long time to wait. Neither is 3 or 4 hours. Patience young grasshopper. Patience.
cotton.ma at 2007-7-14 20:42:49 > top of Java-index,Java Essentials,Java Programming...
# 3

> My applet needs to stream data from a server.

>

> Server is .NET/C#

>

> I have two implementations but both are not the exact

> thing which i want.

> So if anyone have any better ideas please do give

> suggestions.

>

> 1) My server application will write to a hidden

> variable.

> My client java program representing the applet

> have a thread which checksthe value of this

> variable and once the variable gets data use that to

> do the task.

> he task in my scenario is printing.

>

I don't have the slightest clue what this approach entails. None.

> 2) My server will send some text in a specified

> format using the Response.Write() function

>

>My java program reads it using

> ode]

> DataInputStream in = new

> DataInputStream(urlconnection.getInputStream());

> [/code]

>

Okay. So you are using an HttpURLConnection. Good.

> Now the problem with the second implementation is

> response.write() displays the content on the page

What?

> also which makes it visible to all.Also in addition

> to the text written using Reponse.Write() the input

> stream returns all the html tags also.

>

Huh. What? How? What are you doing? Did you actually try this? No you are making wild guesses.

> So can anyone tell me a better way to stream data in

> java.

>

To actually do it rather than making wild and incorrect guesses about what might happen if you actually do anything?

> I know both these implementations are not

> implementing the concept of streaming.

>

You never explained your first implementation.

cotton.ma at 2007-7-14 20:42:49 > top of Java-index,Java Essentials,Java Programming...
# 4

> 2) My server will send some text in a specified

> format using the Response.Write() function

>

>My java program reads it using

> ode]

> DataInputStream in = new

> DataInputStream(urlconnection.getInputStream());

> [/code]

Good choice. :p

A data input stream lets an application read primitive Java data types from an underlying input stream in a machine-independent way.

CeciNEstPasUnProgrammeura at 2007-7-14 20:42:49 > top of Java-index,Java Essentials,Java Programming...
# 5
no its not guess.i tried it and its working.what i need to know is how data is being streamed from server to clients in java.the client in my case is applet and server is .NET/C#
santhoshymaa at 2007-7-14 20:42:49 > top of Java-index,Java Essentials,Java Programming...
# 6
> no its not guess.> Bullshit.Opening a stream from an applet does not make the browser display the content from the stream.This is what you said was happening and is untrue. So please better explain your problem or stop lying.
cotton.ma at 2007-7-14 20:42:49 > top of Java-index,Java Essentials,Java Programming...
# 7

here is my applet code.

checkJavaScriptEvent obj=new checkJavaScriptEvent();

obj.start();

URL currentPage=getCodeBase();

String protocol = currentPage.getProtocol();

String host=currentPage.getHost();

int port=currentPage.getPort();

String urlSuffix="/PrintAppletCSharp/Default.aspx";

System.out.println("currentPage : " + currentPage + "\nprotocol : " + protocol + "\nhost : " + host + "\nport : " + port);

try {

URL dataUrl=new URL(protocol,host,port,urlSuffix);

URLConnection connection=dataUrl.openConnection();

connection.setUseCaches(false);

//connection.setRequestProperty("header", "value");

System.out.println("Got a connection");

//BufferedReader in=new BufferedReader(new InputStreamReader(connection.getInputStream()));

DataInputStream in = new DataInputStream(connection.getInputStream());

//byte[] b=new byte[20];

//int count =is.read(b);

System.out.println("After Getting a connection");// + count + " : " + b.toString());

String line="";

while(!line.equals("EndScriptPrint"))

{

line=in.readLine();

if(!line.equals("StartScriptPrint") && !line.equals("EndScriptPrint"))

fromServer+=line + "\n";

System.out.println("Line " + line);

}

FileWriter fw=new FileWriter("t.txt");

fw.write(fromServer);

fw.close();

Process p=Runtime.getRuntime().exec("notepad.exe t.txt");

repaint();

} catch (Exception ex) {

ex.printStackTrace();

}

santhoshymaa at 2007-7-14 20:42:49 > top of Java-index,Java Essentials,Java Programming...
# 8
Have you signed this applet?
cotton.ma at 2007-7-14 20:42:49 > top of Java-index,Java Essentials,Java Programming...
# 9
no
santhoshymaa at 2007-7-14 20:42:49 > top of Java-index,Java Essentials,Java Programming...
# 10
then you're a looooong way from anything good my friend
cotton.ma at 2007-7-14 20:42:49 > top of Java-index,Java Essentials,Java Programming...
# 11

> what i need to know is how data is being streamed

> from server to clients in java.

Java uses the stream classes. What all others do I don't know. If you don't know what kind of data you're getting from your own services, we are certainly not the ones to ask.

> the client in my case is applet and server is .NET/C#

So what? It could be a COBOL applet for all that matters. It rather looks like you don't understand *what* is sent. How it's sent doesn't matter.

CeciNEstPasUnProgrammeura at 2007-7-14 20:42:49 > top of Java-index,Java Essentials,Java Programming...
# 12
> then you're a looooong way from anything good my> friendBut it works.
CeciNEstPasUnProgrammeura at 2007-7-14 20:42:49 > top of Java-index,Java Essentials,Java Programming...
# 13
> > then you're a looooong way from anything good my> > friend> > But it works.perhaps in appletviewer
cotton.ma at 2007-7-14 20:42:49 > top of Java-index,Java Essentials,Java Programming...
# 14
not only in appletviewer.i called the applet from an aspx page and this page is accessed from a browser,IE.Ok Ceisc, i'll look for Stream Classes.Thank You.
santhoshymaa at 2007-7-14 20:42:49 > top of Java-index,Java Essentials,Java Programming...
# 15
> not only in appletviewer.More bullshit.I give up.
cotton.ma at 2007-7-21 10:02:02 > top of Java-index,Java Essentials,Java Programming...
# 16
Can anbody eventually explain the OP's problem to me? Now he's off searching for appropriate streams, still completely unknowing (it sees) what he's about to receive.And I don't believe the applet will open Notepad from IE. Nor will it connect to any other server.
CeciNEstPasUnProgrammeura at 2007-7-21 10:02:02 > top of Java-index,Java Essentials,Java Programming...
# 17
i don't know how to make u guys believe that i could open a notepad from an unsigned applet.I tried this not only in my machine.ok leave it. thanks for the comments and u people don't need to loose ur temper for a topic like this.thanks.
santhoshymaa at 2007-7-21 10:02:02 > top of Java-index,Java Essentials,Java Programming...
# 18

> ok leave it. thanks for the comments and u people

> don't need to loose ur temper for a topic like this.

It's not the topic. It's the posts.

You're full of ****. You can't do things on the local filesystem from an unsigned applet. It is impossible.

So when are ready to live outside your world of hopeful fantasy do come back and visit us. Until then good riddance.

cotton.ma at 2007-7-21 10:02:02 > top of Java-index,Java Essentials,Java Programming...
# 19
> Can anbody eventually explain the OP's problem to me?Not one clue. He originally asked which of two ways was better but never explained the first way.Then he continues to talk of problems that aren't happening and problems that are happening magically don't exist.
cotton.ma at 2007-7-21 10:02:02 > top of Java-index,Java Essentials,Java Programming...
# 20

> Not one clue. He originally asked which of two ways

> was better but never explained the first way.

He said something about "hidden variable", but I have no idea what he means.

> Then he continues to talk of problems that aren't

> happening and problems that are happening magically

> don't exist.

I've seen stranger things. Maybe he set his sandbox's policy file to allow applets to do everything or something.

CeciNEstPasUnProgrammeura at 2007-7-21 10:02:02 > top of Java-index,Java Essentials,Java Programming...
# 21
> I know both these implementations are not> implementing the concept of streaming.What is "the concept of streaming"?
CeciNEstPasUnProgrammeura at 2007-7-21 10:02:02 > top of Java-index,Java Essentials,Java Programming...
# 22

> > Not one clue. He originally asked which of two

> ways

> > was better but never explained the first way.

>

> He said something about "hidden variable", but I have

> no idea what he means.

Swiss bank variable.

>

> > Then he continues to talk of problems that aren't

> > happening and problems that are happening

> magically

> > don't exist.

>

> I've seen stranger things. Maybe he set his sandbox's

> policy file to allow applets to do everything or

> something.

Occam's razor.

cotton.ma at 2007-7-21 10:02:02 > top of Java-index,Java Essentials,Java Programming...
# 23
> > I know both these implementations are not> > implementing the concept of streaming.> > What is "the concept of streaming"?Become one with the stream man.
cotton.ma at 2007-7-21 10:02:02 > top of Java-index,Java Essentials,Java Programming...