<HTML>
 <HEAD>
 <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <link href="css/sty.css" rel="stylesheet" type="text/css"></link>        
		 <script>
               function enter(){
             if(event.keyCode==13)
  {
      validate();
  }
          }
            function validate()
            {
                  var b=f1.serial.value;
           if((b>='a'&&b<='z')||b==""||b==null)
	window.alert("please enter number");
          
    else {
            document.getElementById('f1').action='dremainder.jsp';
            document.getElementById('f1').submit();
        
        } 
            }
        </script>
    </head>
<body onkeyup="enter()">
<%@page language="java" import="java.util.*,java.sql.*,java.text.*" contentType="text/html"%>
<%
         SimpleDateFormat sdf=new SimpleDateFormat("dd-MM-yyyy");
          
           try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
           
            Connection con=DriverManager.getConnection("jdbc:odbc:letter");
           
            PreparedStatement pstmt = con.prepareStatement("select serial,letterno,lettername,letterdate,demiofficial from i_tappals where action='pending' ");
                      
           ResultSet rs= pstmt.executeQuery();
          out.println("<center><h1><font color=red>Pending Letters</font></h1><hr>");
		  out.println("<table  cellspacing=30 cellpadding=5>");
		  out.println("<tr><td><td>Serial<td>Letterno<td>Lettername<td>LetterDate<td>DO's</tr>");
		  
		   while(rs.next())
            {
			   Timestamp tsp2=rs.getTimestamp(4);
        java.util.Date d2=new java.util.Date(tsp2.getTime());
	 String d11=sdf.format(d2);
String p=rs.getString(5);
if(p==null)
	p="     ";	
			
              out.println("<tr>");
			   out.println("<td><img src='images/bullet.gif'><td>"+rs.getString(1)+"<td>"+rs.getString(2)+"<td>"+rs.getString(3)+"<td>"+d11+"<td style=color:red>"+p);
              out.println("</tr>");
               
              } 
			    out.println("</table></center>");
             }
        
		catch(ClassNotFoundException s)
        { 
	out.println("loaderror");
   	}
		catch(SQLException e)
        { 
	out.println("sqlerror");
   }
                       
           %>
  
  <form name="f1" method="post" id="f1" >
                   <center>
				   <h1>Generate Remainder</h1>
<hr>
	
		 <% if(request.getAttribute("insert")!=null){%>
   <b><h1> <font color="green"><%=(String) request.getAttribute("insert")%></font></h1></b>
    <%}%>

        <% if(request.getAttribute("error")!=null){%>
   <b><h1> <font color="red"><%=(String) request.getAttribute("error")%></font></h1></b>
    <%}%>
    <table cellspacing=10 cellpadding=5>
          <tr> <td>
                LetterSerial no:
            </td>
            <td>
            <input type="text" name="serial"></td>
        </tr>
        <tr>
            <td><input type=button value="Generate" onclick="validate()"></td>
            <td><input type="reset" value="Cancel"></td>
        </tr>
        </table>
    </center>
    </form>
   </body>
</html>