views:

13

answers:

1

Hi I have to design such that whenever user pass a query I process it using servlet and then call the js page to draw the chart

1> user writes a query on a page 2> the page call the servelt class public class MyServlet extends Httpservlet implements DataSourceServlet {..... return data The user see a beautiful string like this.. google.visualization.Query.setResponse......... /Tiger'},{v:80.0}, {v:false}]}]}}); 3> when the user hits on different html page myhtml.js it draws the chart.

I want the Myservlet class itself call the myhtml.js page and draw the chart directly. and want to eliminate the beautiful string google.visualization.Query.setResponse......... /Tiger'},{v:80.0}, {v:false}]}]}}); from coming on user's browser What should i do? I tried using functions to call another page like request dispatcher(), redirect() calling myhtml.js page directly after myservlet process the query results. But i get the result like this google.visualization.Query.setResponse......... /Tiger'},{v:80.0}, {v:false}]}]}}); and the entire myhtml.js code page below it on the browsers that to without the chart been draw.

Is there anyway to element the beautiful string from coming on clients browser and only show them the chart been drawn ? :)

This is the small tutorial i am following http://code.google.com/apis/visualization/documentation/dev/dsl_get_started.html

A: 

It is a bit difficult to follow, but I think you approach the problem from the wrong side.

As HTTP is essentially a PULL technology it is much easier to have the HTML page call the myhtml.js funtionality and request the data from the servlet.

Calling browserside javascript from servlets is not really possible without considerable inrastructure which is probably not what you want, i.e. a lean/simple solution.

Peter Tillemans
But for processing I have to call servlet and once the processing is done i call the html page.My problem is that after servlet process the data... it reflect a json string on the browser without any stream writer I donno why this happens. And only when the json string is seen on the broswer I have to call the html page seperatly to see the chart.If i use redirect or forwad , include the chart is not drawn seens the json string has not appeared on the browser.So how can let call the html page from servlet after some time interval.I tried thrd sleep ,refresh method but that did not help me
akshay
You create your HTML page. In the HTML page (using the onLoad event or similar) you launch the AJAX request to the servlet to get the data for the chart. In this case you'll pass 2x to the servlet but the servlet never has to "call" the page.
Peter Tillemans
@peter i will follow your solution and post it if that works.so to sum it up when a client sends a query via html page the server process the query and response a string on the clients browser.Once the string appears on the browser. the client can hit another html page and see the chart.The client can only see the chart if he hits the html chart address after the server response the visible string to the clients browser.
akshay
@peter i am very new to ajax and stuff but i believe the ajax has the power to detect wether the response from the server has reached the browser ..... peter if you explain the solution further it will be of grate helpThanks
akshay
Ajax is powerful, but it does not change the law of physics. In essence the web is pull technology from the browser's perspective. Now you do not need another HTML page, however you need your page to ask for an image (or similar) to fill in the graph, well at least you would if you use 20th centure technology. Now we use Javascript to ender a graph in a div and get the data from the server. So, in short, you have your HTML page, with the graph javascript library, the div where you want to graph to appear, and an onLoad event to trigger the javascript to mget the dat from the server
Peter Tillemans