Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have to make call to a web service which will send a compressed (ZLIB) stream back to me. I have to de-compress the same stream and use it further.

My problem is that I have to get it done on the client side using JavaScript/Ajax/JQuery etc.

I already have code written/working in Java as below, but now the requirement has changed and we have to process it client side.
C#
url = new URL(getCodeBase(), dataSrcfile); 
URLConnection urlConn = url.openConnection();
UrlConn.setUseCaches(false); 
InputStream in = urlConn.getInputStream();
InflaterInputStream inflate = new InflaterInputStream(in);
InputStreamReader inputStreamReader = new InputStreamReader(inflate);
BufferedReader bufReader = new BufferedReader(inputStreamReader);

int i = 0;
int nHidden = 0;
String line1;
do //------------------------Parsing Starts Here
{
line1 = bufReader.readLine();
if ((line1 != null) && line1.startsWith("#"))
{
StringTokenizer line1Tokens = new StringTokenizer(line1, "	");
nHidden = line1Tokens.countTokens() - 1;
HiddenArray[Num] = new String[nHidden];
String Type = line1Tokens.nextToken();
while ((line1Tokens.hasMoreTokens()) && (i < nHidden))
{
HiddenArray[Num][i++] = line1Tokens.nextToken();
}
}
Posted
Updated 22-Dec-10 2:11am
v2
Comments
Sandeep Mewara 22-Dec-10 8:11am    
From next time, use PRE tags to format your code part. It makes the question readable.
Manfred Rudolf Bihy 24-Dec-10 12:48pm    
How's it going any progress so far?

1 solution

Since you already have java code, why not wrap that into an applet. You can google "applet java javascript communication" on how to communicate with your applet from javascript. One link leads right back here for an article on that:

http://www.codeproject.com/KB/scripting/javatojs.aspx[^]

Hope it helps!

Regards,

Manfred
 
Share this answer
 
Comments
Rajeev Raina 23-Dec-10 0:25am    
Sorry, I can not use any server side technology. I already have Applet doing what I am supposed to do, but now my client does not want to run anything on the sever and I have to habdle it client side only.
Manfred Rudolf Bihy 23-Dec-10 4:11am    
Applets run on the client side. Read all about it here:
http://java.sun.com/applets/
and here:
http://en.wikipedia.org/wiki/Java_applet
The first couple of sentences make it pretty clear that applets are client side technology. Maybe you want to look at an example that includes a little demo too:
http://www.raditha.com/java/mayscript.php

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900