how to display differnt time fields in a single column?

[nobr]Hello Sir,

I am trying to display the records which show the table with 3 columns filename,Date,status using jsp.

I am fetching the records from the DB and displaying them using jsp ,connection,resultset, <table> etc.

what i wanted to display is just 3 colms(filename,date,status)

here based on the status it should display the date,becaz table contains different date fieldcolumn for each status value.

here is my code:

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<title>Content Dash Board</title>

</head>

<body>

<%@ page import="java.sql.*" %>

<%@ page import="java.text.*" %>

<% Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();%>

<%

int current = 1;

if(request.getParameter("current") !=null){

current = Integer.parseInt(request.getParameter("current"));

}

int skip = 5;

String action ="";

if(request.getParameter("action") !=null){

action = request.getParameter("action");

}

if ( action.equals("next") ){

current += skip;

}

if ( action.equals("prev") ){

current -= skip;

}

%>

<HTML>

<HEAD>

<TITLE>Content Dash Board </TITLE>

</HEAD>

<FORM NAME="form1" ACTION="dashboard.jsp" METHOD="POST">

<%

Connection conn = DriverManager.getConnection

("jdbc:microsoft:sqlserver://localhost:1433;databaseName=trax;selectMethod=cursor","sa","iso*help");

Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);

ResultSet resultset =

stmt.executeQuery("select * from ContentBatches");

resultset.last();

int rows = resultset.getRow();

if ( current >= rows ) current = rows-skip;

if ( current < 0 ) current = 1;

resultset.absolute(current);

%>

<TABLE BORDER="1">

<TR>

<TH bgcolor=#C6C3C6>File/BatchName</TH>

<TH bgcolor=#C6C3C6>Date</TH>

<TH bgcolor=#C6C3C6>Status</TH>

</TR>

<%

int i=0;

boolean next =false;

java.text.SimpleDateFormat fmt=new java.text.SimpleDateFormat("EEE, MMM d, yyyy K:mm a ");

DecimalFormat df =new DecimalFormat("###,###,###,000,000" );

String filename=null;

String status=null;

do{

i++;

filename=resultset.getString(2);

status=resultset.getString(8);

%>

<TR>

<TD> <%= filename %> </TD>

<%

if(status.equals("Received"))

{

out.println("status is:"+status+"time stamp is :"+fmt.format(resultset.getTimestamp(7)));

%>

<TD><%= fmt.format(resultset.getTimestamp(7)) %></TD>

<%

}

elseif(status.equals("Validated"))

{

%>

<TD><%= fmt.format(resultset.getTimestamp(5)) %> </TD>

<%

}

elseif(status.equals("Published"))

{

%>

<TD><%= fmt.format(resultset.getTimestamp(4)) %> </TD>

<%

}

elseif(status.equals("Uploaded"))

{

%>

<TD><%= fmt.format(resultset.getTimestamp(6)) %> </TD>

<%

}

else

{

%>

<TD>No dataforthis option</TD>

<%

}

%>

<TD> <%= status%></TD>

<td><a href="edit.jsp?BatchId=<%=resultset.getString(2)%>&DateTimeStampPublished=<%=resultset.getString(4)%>&Status=<%=resultset.getString(8)%>">Edit</a></td>

</TR>

<%

}

while((next=resultset.next()) && i<skip);

%>

</TABLE>

<BR>

<INPUT TYPE="HIDDEN" NAME="current" VALUE="<%=current%>">

<INPUT TYPE="HIDDEN" NAME="action" VALUE="next">

<%

if(next){

%>

<INPUT TYPE="BUTTON" VALUE="Next Record" ONCLICK="moveNext()">

<%

}

if(current > 0){

%>

<INPUT TYPE="BUTTON" VALUE="Previous Record" ONCLICK="movePrevious()">

<%

}

%>

</FORM>

<SCRIPT LANGUAGE="JavaScript">

function moveNext()

{

form1.action.value ='next';

form1.submit()

}

function movePrevious()

{

form1.action.value ='prev';

form1.submit()

}

</SCRIPT>

</body>

</html>

[/nobr]

[7827 byte] By [Annamalaii1a] at [2007-10-3 3:26:14]
# 1

> I am fetching the records from the DB and displaying

> them using jsp

I refuse to help people that do that. A JSP should contain as little logic as possible, and should certainly not access a DB. If at all, it's a Servlet's job, but it's best left to the business tier. This is horrible application design.

CeciNEstPasUnProgrammeura at 2007-7-14 21:19:23 > top of Java-index,Java Essentials,New To Java...
# 2
i am very new to jsp sir, i haven't worked on servlet , how do i implement the same code in servlet could you provide me the steps , putting jar files and all ?
Annamalaii1a at 2007-7-14 21:19:23 > top of Java-index,Java Essentials,New To Java...
# 3

> i am very new to jsp sir, i haven't worked on servlet

> , how do i implement the same code in servlet

> could you provide me the steps , putting jar files

> and all ?

I'm not here to tutor you. You can read this:

http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets.html

Servlets aren't difficult, and actually JSPs are nothing but servlets with a different syntax either.

CeciNEstPasUnProgrammeura at 2007-7-14 21:19:23 > top of Java-index,Java Essentials,New To Java...