Problem in Displaying the Mysql data in Frontend

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xtremebass
    New Member
    • Nov 2008
    • 38

    Problem in Displaying the Mysql data in Frontend

    Hi ,
    i have created table with only one field for the type of varchar(8000) . I am stroed bulk amount of data in that field.

    The size i have specified is enough for the field to occupy my data.

    I am storing "Text file" as Data to that filed.when i am viewing contents present in the table it shows what actual contents present in that text file like one by one line of data.

    But when i am reterving the data in the browser using Jsp, it shows all contents present in the filed is displayed without any alignment. i want see output as i have seen/stored in the database.

    could please suggest me the right way to proceed this is problem .. is this the problem in mysql or Jsp?
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    The problem is in your jsp code. The JSP display uses html so you need to convert the newlines from table to <BR /> tags.

    Comment

    • xtremebass
      New Member
      • Nov 2008
      • 38

      #3
      Thanks for Reply.

      I did jsp code with <br> tag. but still problem comes while displaying the records from mysql database. it shows the contents with no alignment of data.
      here is the code
      Code:
      <%@ page import="java.sql.*" %>
      <%@ page import="javax.servlet.*" %>
      <%@ page import="javax.sql.*" %>
      <%@ page import="javax.servlet.http.*" %>
      
      <%
      ResultSet rs=null;
      Connection con =null;
       %>
      
      <html>
      <head>
      <h3>Sample Database Reterival</h3></head>
      <table><tr><th>Memory Information</th></tr>
      
      <body>
      
      <%
      try
      {
      Class.forName("com.mysql.jdbc.Driver");
      con=DriverManager.getConnection("jdbc:mysql://192.168.1.8:3306/test","root","prastsys");
      Statement st=con.createStatement();
      rs=st.executeQuery("select * from charchk");
      while(rs.next())
      {
      String mem=rs.getString(1);
      %>
      
      <tr>
      <td>
      <%
      out.println(mem);
      %>
      <br>
      </td>
      <br>
      </tr>
      <%
      }
      %>
      </table>
      <%
      }
      catch(Exception e)
      {
      out.println(e);
      }
      %>
      
      </body>
      </html>
      Data present in the table is shown below
      Code:
      mysql> select * from charchk;
      +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
      | memory                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
      +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
      |         total:    used:    free:  shared: buffers:  cached:
      Mem:  515952640 510210048  5742592        0  2199552 118583296
      Swap: 1077469184 572231680 505237504
      MemTotal:       503860 kB
      MemFree:          5608 kB
      MemShared:           0 kB
      Buffers:          2148 kB
      Cached:          62224 kB
      SwapCached:      53580 kB
      Active:         382952 kB
      ActiveAnon:     354608 kB
      ActiveCache:     28344 kB
      Inact_dirty:     72288 kB

      reply if any other option is there to split contents in present in the one field of particular table when display the jsp page in Browser..

      output from browser:

      Sample Database Reterival

      Memory Information
      total: used: free: shared: buffers: cached: Mem: 515952640 510210048 5742592 0 2199552 118583296 Swap: 1077469184 572231680 505237504 MemTotal: 503860 kB MemFree: 5608 kB MemShared: 0 kB Buffers: 2148 kB Cached: 62224 kB SwapCached: 53580 kB Active: 382952 kB ActiveAnon: 354608 kB ActiveCache: 28344 kB Inact_dirty: 72288 kB Inact_laundry: 14928 kB Inact_clean: 6720 kB Inact_target: 95376 kB HighTotal: 0 kB HighFree: 0 kB LowTotal: 503860 kB LowFree: 5608 kB SwapTotal: 1052216 kB SwapFree: 493396 kB HugePages_Total : 0 HugePages_Free: 0 Hugepagesize: 4096 kB
      Last edited by Atli; Nov 13 '08, 12:55 PM. Reason: Added [code] tags around the query

      Comment

      Working...