How to design this ?

Posted by Akku on Stack Overflow See other posts from Stack Overflow or by Akku
Published on 2010-06-10T20:02:33Z Indexed on 2010/06/11 17:12 UTC
Read the original article Hit count: 372

how can i make this entire process as 1 single event???

http://code.google.com/apis/visualization/documentation/dev/dsl_get_started.html

and draw the chart on single click?

I am new to servlets please guide me

When a user clicks the "go " button with some input. The data goes to the servlet say "Test3". The servlet processes the data by the user and generates/feeds the data table dynamically Then I call the html page to draw the chart as shown in the tutorial link above.

The problem is when I call the servlet it gives me a long json string in the browser as given in the tutorials

"google.visualization.Query.setResponse({version:'0.6',status:'ok',sig:'1333639331',table:{cols:[{............................" 

Then when i manually call the html page to draw the chart i am see the chart.

But when I call html page directly using the request dispatcher via the servlet I dont get the result.

This is my code and o/p...... I need sugession as to how should be my approach to call the chart

public class Test3 extends HttpServlet implements DataTableGenerator {
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
 DataSourceHelper.executeDataSourceServletFlow(request, response,  this , isRestrictedAccessMode() );


            RequestDispatcher rd;
         rd = request.getRequestDispatcher("new.html");// it call's the html page which draws the chart as per the data added by the servlet.....
         rd.include(request, response);//forward(request, response);

  @Override
  public Capabilities getCapabilities() {
    return Capabilities.NONE;
  }


protected boolean isRestrictedAccessMode() {
    return false;
  }

 @Override
  public DataTable generateDataTable(Query query, HttpServletRequest request) {
    // Create a data table.
    DataTable data = new DataTable();
    ArrayList<ColumnDescription> cd = new ArrayList<ColumnDescription>();
    cd.add(new ColumnDescription("name", ValueType.TEXT, "Animal name"));
    cd.add.........

I get the following result along with unprocessed html page

google.visualization.Query.setResponse({version:'0.6',statu.....
<html>
<head>
  <title>Getting Started Example</title>
.... Entire html page as it is on the Browser.

What I need is when a user clicks the go button the servlet should process the data and call the html page to draw the chart....Without the json string appearing on the browser.(all in one user click)

What should be my approach or how should i design this.... there are no error in the code. since when i run the servlet i get the json string on the browser and then when i run the html page manually i get the chart drawn.

So how can I do (servlet processing + html page drawing chart as final result) at one go without the long json string appearing on the browser. There is no problem with the html code....

© Stack Overflow or respective owner

Related posts about servlets

Related posts about google-visualization