This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

display problem.

 
jyotsana dang
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • 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..
 
lali virdi
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • 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
 
Praful Thakare
Ranch Hand
Posts: 642
  • Mark post as helpful
  • send pies
  • 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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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..
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic