File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes consuming data from StreamHub Reverse Ajax & Comet Server via a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "consuming data from StreamHub Reverse Ajax & Comet Server via a servlet" Watch "consuming data from StreamHub Reverse Ajax & Comet Server via a servlet" New topic
Author

consuming data from StreamHub Reverse Ajax & Comet Server via a servlet

jite eghagha
Ranch Hand

Joined: Oct 06, 2006
Posts: 127
hi,

I'm using a StreamHub Reverse Ajax & Comet Server to pass data to all clients. What one client sends out -- all clients see.

I'd like to have a Servlet that captures ALL traffic (data) that comes into the SteamHub server. (to do some processing of the data)

The trouble: a client (html or jsp page) that consumes data from the StreamHub server uses a javascript file streamhub-min.js

Client header:




The question: if a "servlet was a client to StreamHub server", how do i include, and use streamhub-min.js functions ?
Fatih Keles
Ranch Hand

Joined: Sep 01, 2005
Posts: 182
jite eghagha wrote:
I'd like to have a Servlet that captures ALL traffic (data) that comes into the SteamHub server. (to do some processing of the data)

So your SteamHub server is located at some URL and you can write a Filter -not a servlet- to capture the request made by clients to that URL. No difference if the request is done by javascript. Some where in streamhub-min.js file there must be URL defined for requests.

jite eghagha wrote:
The question: if a "servlet was a client to StreamHub server", how do i include, and use streamhub-min.js functions ?

Inside servlet code accesing js code is irrelevant since servlet is server-side and js is client-side.

Regards,

Fatih.
jite eghagha
Ranch Hand

Joined: Oct 06, 2006
Posts: 127
I understand,

however, let me give a scenario in which i am dealing with Lat / Lng on my SteamHub server:

the google map api has a method.........containsLatLng(latlng:GLatLng) which ...........Returns true if the geographical coordinates of the point lie within this rectangle.

Without using google maps, i don't know of any other way beside mysql or oracle server to get such a function.

how do i call this method in a servlet or any other server side class?

I've notice code here and there in .net, (i may be horribly wrong on that) where people handle google maps on the server side of things



Fatih Keles
Ranch Hand

Joined: Sep 01, 2005
Posts: 182
I suppose you have to obtain data from an outer source -google maps- that is commonly accessed through a javascript Ajax call from browser within your server side code. Here are the things that comes to my mind:

1) You can find some tricky way to make your client's browser do the request and get data and if necessary bring it to your server side code.
2) Ajax calls are certainly like any other http request, so you may analyze the javascript code that makes the exact request you want to imitate with firebug or some other js debug tool and learn http post variables and imitate it in your server side code. Some proxy code will make the request and get data and parse it and return it to you.

I don't know your exact requirements but either of these may work according to your requirements.

There can be a java client to your service distributed by the service implementors that does what js client does. But I guess there is not,
see this: http://stackoverflow.com/questions/996954/java-api-for-google-maps-or-similar
and this: http://groups.google.com/group/Google-Maps-API/browse_thread/thread/0a0e77fb36769820

I did not inspected deeply but this one seems to use the first approach using php : http://eriestuff.blogspot.com/2008/02/google-maps-point-in-polygon.html

Regards,

Fatih.
 
wood burning stoves
 
subject: consuming data from StreamHub Reverse Ajax & Comet Server via a servlet