• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

display problem.

 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i wrote the following jsp code to browse my records ..

<%@ page language="java" import="java.sql.*,java.io.*,java.util.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Faculty- Dept. Of Mech. Engg.-Home Page</title>
</head>
<body>
<div align="center"><b><font face="Georgia, Times New Roman, Times, serif">Display
Records</font></b>


<%
Connection con=null;
java.sql.Statement stmt=null;
ResultSet rs=null;
boolean y=false;
int i;
String username=(String)session.getAttribute("y");
out.print("<h4><pre>");
out.print("<font face=Georgia color=green>");
out.print("From \t Year \t To \t Year \t Semester");
out.print("Program\tCourse\tCourseNo\t Course Title\tLoadTaken\n</font>");
out.print("</h4>");

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc dbc:mech_iit");
stmt=con.createStatement();

rs=stmt.executeQuery("select * from teaching_load where user_login='"+username+"' order by from_month desc");

while(rs.next()) {

out.print(rs.getObject(2).toString());
out.print(rs.getObject(3).toString());
out.print(rs.getObject(4).toString());
out.print(rs.getObject(5).toString());
out.print(rs.getObject(7).toString());
out.print(rs.getObject(8).toString());
out.print(rs.getObject(9).toString());

}
}
catch(Exception e)
{
System.out.println("exception in block"+e);
}
rs.close();
con.close();

%>
</div>
</BODY></HTML>
Iam getting a problem in displaying my output properly..
The column names of the tables are displayed but iam not getting the records in the right order..that is under each column name..the records are being displayed widely apart from each other..
any idea of the html tags to be used in the while loop that i have used..
thanks..
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<% jsp code %>
<table>
<% while(rs.next()) { %>
<tr><td>
<% out.print(rs.getObject(2).toString()); %>
</td>
<td>
<% out.print(rs.getObject(3).toString()); %>
</td><td>
out.print(rs.getObject(4).toString());
out.print(rs.getObject(5).toString());
out.print(rs.getObject(7).toString());
out.print(rs.getObject(8).toString());
out.print(rs.getObject(9).toString());
to this for all they will align
 
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jyotsana,
Try to display your data in table,using <tr><td>.
this will help you to aligne text.
Cheers
Praful
[ February 12, 2004: Message edited by: Praful Thakare ]
[ February 12, 2004: Message edited by: Praful Thakare ]
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Praful,
JavaRanch is a community of people from all over the world, many of who are not native English speakers. While using abbreviations like "u" instead of spelling out "you" is convenient when text messaging your friends on a cell phone or in a chat room, it presents an extra challenge to those that are already struggling with English. I would like to ask for your help in making the content of JavaRanch a little easier to read for everybody that visits here by not abbreviating such words.
thanks,
bear
JSP Forum Bartender
 
jyotsana dang
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by lali virdi:
<% jsp code %>
<table>
<% while(rs.next()) { %>
<tr><td>
<% out.print(rs.getObject(2).toString()); %>
</td>
<td>
<% out.print(rs.getObject(3).toString()); %>
</td><td>
out.print(rs.getObject(4).toString());
out.print(rs.getObject(5).toString());
out.print(rs.getObject(7).toString());
out.print(rs.getObject(8).toString());
out.print(rs.getObject(9).toString());
to this for all they will align



thanks.. i guess that is a better way of doing..
 
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out the FormattedDataSet for an easy, flexible way to display dynamic content. The live demo available at http://www.fdsapi.com allows you to enter ANY query and have it formatted in a way similar to what you are trying to do. This is however just the tip of the iceberg as far as the capabilities of the FormattedDataSet are concerned.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic