It's not a secret anymore!*
The moose likes JSP and the fly likes display problem. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "display problem." Watch "display problem." New topic
Author

display problem.

jyotsana dang
Ranch Hand

Joined: Sep 26, 2003
Posts: 135
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

Joined: Feb 09, 2004
Posts: 19
<% 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

Joined: Feb 10, 2001
Posts: 614
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 ]

All desirable things in life are either illegal, banned, expensive or married to someone else !!!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
jyotsana dang
Ranch Hand

Joined: Sep 26, 2003
Posts: 135
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

Joined: Jun 26, 2002
Posts: 860
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.


http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: display problem.