Dear All,
 
    Problem :
                    I have a jsp page, which should talk to database and fetches file name from the table and prints the file on to browser.
 
    Current Result :
                    No error, but there is no single data from the file are not written to the browser.
 
    Request :
                    Can any body send me the code for my requirement, earliest.
 
Code :
 
<%--
 * PrintFiles.jsp
 * Created on December 13, 2001, 4:00 PM
--%>
 
<%@ page import = "java.io.*" %>
<%@ page import = "java.sql.*" %>
<%@ page import = "javax.servlet.*" %>
 
<%--
 * @author Ravindra Varna
 * @version 1.0.0
--%>
<html>
 <body bgcolor = "#246890">
  <%!
   Connection con;
   CallableStatement cstmt;
   ResultSet rs;
   String Hi = "Ravindra Varna";
   PrintWriter out;
  %>
  <%!
   void getConnection()
   {
    try
    {
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     con = DriverManager.getConnection("jdbc:odbc:DB","sa","");
    }catch(Exception e)
    {
     
file://out.println(e);
    }
   }
  %>
  <%=Hi %>
  <%!
   void getResultSet()
   {
    String mysql_Statement;
    String file_Name;
    try
    {
     mysql_Statement = "{call DB_Sl_FileName}";
     cstmt = con.prepareCall(mysql_Statement);
     rs = cstmt.executeQuery();
     
     while (rs.next())
     {
      file_Name = rs.getString(2);
      FileReader fr = new FileReader(file_Name);
      int c = 0;
      while (c != -1)
      {
       c = fr.read();
       out.println((char)c);
      }
     }
    }catch(Exception e)
    {
     out.println(e);
    }
   }
  %>
  <%=Hi %>
 </body>
</html>
 
 
 
 
Thanks
 
Varna.

Reply via email to