-1

Image is shown here

How to display the result shown above to be displayed in table in separate columns using JSP. The result now is in String format. I want the "success" column data to be displayed vertically . Likewise all other columns.

I am directly displaying the object from the method to the JSP file which is in string format.

<%=object.Significance()%> this is the method returning the object which is in string format.

Here goes the code:

public String Significance() throws RserveException, REXPMismatchException {

        RConnection conn = new RConnection();
        String filename="D:/significance.csv";
        StringBuilder sb = new StringBuilder();
        sb.append("user <-read.csv(\"");
        sb.append(filename);
        sb.append("\")");
        conn.eval(sb.toString());
        conn.eval("library('bandit')");
        conn.eval("sa=bandit::significance_analysis(register,visitors)");
        conn.eval("analysis=sa[rev(order(sa$estimated_proportion)), ]");
        conn.eval("library('RJSONIO')");
        conn.eval("jsonval <- toJSON(analysis)");           
        REXP resultvalue = conn.eval("toString(jsonval)");
        String jsonobject1=resultvalue.asString();
        System.out.println(jsonobject1.toString());
        return jsonobject1;
}

Returning the object in JSP page like this:

<%
com.abtesting.SignificanceAnalysis object2 = new com.abtesting.SignificanceAnalysis();
String significance=object.Significance();
%>

<%=significance%>;
Arun Xavier
  • 763
  • 8
  • 47
Preethi
  • 33
  • 8
  • What have you tried so far? Where are you stuck? Have you tried the `String.split` method yet? Also please implement the images instead of linking them. – ctst Feb 29 '16 at 09:30
  • @ctst, Yes I have tried split method too, but the problem is the whole values gets split, giving series of vertical values. I want it in table format. – Preethi Feb 29 '16 at 09:33
  • Then insert every 9th element a new row, since your Significance seems to have a known fix number of elements per row. – ctst Feb 29 '16 at 09:36
  • @Preethi , could you remove the image and post a sample string content ? – Arun Xavier Feb 29 '16 at 09:38
  • Preethi, cannot see an attempt to use Table Rows and Tds to arrange the data properly – Kiran Krishnan Feb 29 '16 at 09:49
  • @KiranKrishnan, So, Are there any other method to do it? – Preethi Feb 29 '16 at 09:53
  • @Preethi, if the result is in Json, can you decode the Json to array, so that you can loop over each element . Can you check this ? http://www.coderanch.com/t/650404/JSP/java/apprach-parse-JSOn-send-JSP – Kiran Krishnan Feb 29 '16 at 09:54
  • did you tried using json ? reference question [Convert a JSON string to object in Java?](http://stackoverflow.com/a/1396087/4290096) – Arun Xavier Feb 29 '16 at 09:54
  • @KiranKrishnan Thank you. Will check this. – Preethi Feb 29 '16 at 09:56

2 Answers2

1

Use jqgrid to display the json values in a table.

Create json array ,json object in java code and then use jqgrid in jsp page ang diplay the values in the table.

Preethi
  • 33
  • 8
0

there is one best jquery plugin called jquery DataTable plugin. https://www.datatables.net/

it take json as input and show in table view. with all options like pagination, next page, searching and ordering

try it.

Musaddique S
  • 1,539
  • 2
  • 15
  • 36
  • Thank you so much.. Will try it . – Preethi Feb 29 '16 at 09:56
  • This is also good way to reduce overhead on development. But , has to understand what is the built in options for converting in betwwen different data objects like Json -> Array or objects etc !!!!! – Kiran Krishnan Feb 29 '16 at 09:58
  • @TipuSultan JSON object is returned from the method. How can I show that in the table? – Preethi Feb 29 '16 at 10:13
  • as you know in jquery plugin it accept json from ajax call. so please create servlet and in that servlet write json n PrintWriter. – Musaddique S Feb 29 '16 at 10:44