Hi,
I am developing a site using JSPs and .java files (No beans being
created for now). The JSWDK server crashes after it executes and displays
Screen.jsp file (sequence shown below)
Environment:
NT 4.0, JDK 1.2.2, JSWDK 2.1
Scenario:
Login.jsp ---> Project.jsp ---> Screen.jsp ---> Control.jsp
As soon as a request for a JSP file is received by the web server,
it invokes the constructor in the respective .class file and creates a
connection to the SQL 7.0 database. The code for the Screen processing is
given for reference.
I am unable to find valid a reason for this. Has anybody ever faced a
similar situation...? Where am I going wrong?
//Code for processing screen.jsp file
public class WebPage
private Connection con=null;
private Statement stmt;
public WebPage() {
try {
getConnection();
if(con==null) {
msg("Connection for screen could not be
created...");
return;
}
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}
private void getConnection() throws SQLException
{
try {
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:TEST";
con = DriverManager.getConnection(url);
} catch(Exception CNFE){
System.out.println(CNFE.getMessage());
}
}
protected void finalize() throws Throwable
{
if (stmt != null) {
try {
stmt.close();
} catch(SQLException ex) {
msg(ex.getMessage());
} catch(Exception ex) {
msg(ex.getMessage());
}
}
if (con != null) {
try {
con.close();
} catch(SQLException ex) {
msg(ex.getMessage());
} catch(Exception ex) {
msg(ex.getMessage());
}
}
}
//Other business specific methods go here...
}
Regards
Ashish
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets