Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
You've gotta fight it! Don't give in! Read this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic