i have written a
Servlet which talks to the database fetches some data and prints it out in the browser.I was successfully able to compile the servlet class but when i deploy the same in
tomcat a blank screen occurs.
I checked the table in the database.It has some records.
web.xml is perfectly fine and the utl-pattern perfect.
I checked tomcat logs.But they are also perfect.
However i did not have any luck with the output and always see a BLANK SCREEN
javascript: x()
banghead
Here's my Code
package com.encore;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class FileUploadServlet extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)throws IOException,ServletException {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
//Oracle Database Connection Starts
try {
//Load and Register the oracle driver
Class.forName("oracle.jdbc.driver.OracleDriver");
//Get a connection to the database
conn = DriverManager.getConnection("jdbc
racle:thin:@kaikeyee:1521:enr9i","TNS51628","TNS51628");
//Create a Statement object
stmt = conn.createStatement( );
//Execute a SQL statement , get a resultset
rs = stmt.executeQuery("select name,phone from employees");
//Display the result set as a list
pw.println("<html><head><title>PhoneBook</title></head>");
pw.println("<body>");
pw.println("Inside the Database Servlet class");
pw.println("<ul>");
while(rs.next( )) {
pw.println("<LI>"+rs.getString("name")+ " " + rs.getString("phone"));
}
pw.println("</ul>");
pw.println("</body></html>");
}
catch(SQLException se){
System.out.println("SQL Exception rajat:" + se.getMessage());
se.printStackTrace(System.out);
}
catch(ClassNotFoundException cnfe){
System.out.println("ClassNotFounException found");
}
//Oracle Database connection ends
finally {
try {
if(conn!=null){
conn.close();
}
}catch(SQLException ignored){}
}
}
}