0

1.I have a format required to be displayed in jsp. Where the rows should be displayed row wise.

2.These values(numbers) are dynamic i.e if the data is present in database i will get values else 0 will be got

3.The values are retrieved from database using ArrayList Concept

4.Data should be displayed in table format .

I have a format but not able to post it as image please let me know how can upload the format.

    AAAA    BBBBB   CCCCCC
A   3        4       0
B   43       3       2
C   0        3       3
    enter code here
    Connection con=null;
    Statement st= null;
    PreparedStatement pstmt=null;
     ResultSet x=null;
    String s1="";
    String age="";
    String s="";
    String tot="";
    %>

    
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con=DriverManager.getConnection("jdbc:odbc:sup_sup","scott","tiger");
    st=con.createStatement();
    x=st.executeQuery("SELECT name,COUNT(age)  ,COUNT(*) - COUNT(age) ,COUNT(*)  FROM supreeth_table GROUP BY name");

    %>
    

    ");
    out.println("NAME");
    while(x.next())
    {    
    out.println(""+x.getString(1)+"" );

    }
    out.println("");
    out.println("");
    out.println("NAMESS");
    while(x.next())
    {    
    out.println(""+x.getString(2)+"" );
    }
    out.println("");
    out.println("N");
    out.println("");
    out.println("A");
    out.println("");
    out.println("NA");
    %>
    
    
    
    

    

this is what the best could put up . Sorry with formatting I'm new to this

these data should be got from database in the same format. using arraylist,jsp.

Now i have tried to put the code i was trying pls help me out with answers Thank you in advance !!!

4
  • Not sure what you mean here. Can't you just pass the model to the view and use <c:each /> + <c:out> here? Commented Jul 4, 2013 at 13:23
  • hmmm? can you post what you have so far? Commented Jul 4, 2013 at 13:29
  • this should help: docs.oracle.com/javaee/1.4/tutorial/doc/JSPIntro7.html Commented Jul 4, 2013 at 13:35
  • @ErikPragt : hi sir now can you please give me some ideas Commented Jul 4, 2013 at 15:40

1 Answer 1

3

Its not clear what you are saying here but I guess you are trying to get the output in a table format. Use table tags for it

<table>
<%
  while(x.next())
  {%>
  <tr>
   <td><%out.print(x.getString(1); %></td>
    <td><%out.print(x.getString(2); %></td>
    <td><%out.print(x.getString(3); %></td>
   </tr>
   <% 
   }
   %>

hope this would solve your formatting problem. For displaying images from your database you must fetch the image name from your data base where you fetch all other data. Say you add another field in your query as image. Now to display that image you must have that image in your project images folder. Following code would help you to get image.

<table>
<%
  while(x.next())
  {%>
  <tr>
   <td><img src="/images/<%out.print(x.getString(1)"; %></td>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.