Craig,
Something interesting happening over here with Tomcat Beta 7 that might
interest you, or perhaps you can provide a solution for the problem I am
experiencing. After installing Tomcat 4, I built a very simple servlet for
testing purposes. This particular servlet compiled and executed without any
problem. Several day's later, I wrote a new servlet for jdbc testing. When I
compiled the java file, it failed. At the same time while attempting to
rebuild the original test servlet code under a different file name, the same
error occurred. It seems as though I can no longer compile my java files
successfully. Below is the servlet code, a copy of my autoexec.bat file, and
the error I am receiving. If this is a bug, I hope I have been helpful, and
if its something I'm doing wrong, I would appreciate some help at resoving
this.
OS: Windows 98
autoexec.bat:
PATH=%PATH%;"C:\Program Files\Mts;C:\jdk1.3.0_02\bin
CLASSPATH=C:\jdk1.3.0_02
set JAVA_HOME=C:\jdk1.3.0_02
set CATALINA_HOME=C:\work\pkgs\tomcat4
Original successfully compiled Servlet:
For your convenience, I have attached the file. I hope that user email
application allows for this.
javac compilation error message's;
cannot resolve symbol
MyFirstServlet2.java: 10 HttpServletResponse
cannot resolve symbol
MyFirstServlet2.java: 10 ServletException
Brian
package com.wrox.projsp.ch03.myfirstwebapp;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;
public class MyFirstServlet2 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
response.setContentType("text/plain");
PrintWriter out = response.getWriter();
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
String error = null;
String docType = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0" +
"TRANSITIONAL//EN\">\n";
out.println(docType + "<HTML>\n" + "<HEAD><TITLE>Servlet Database JDBC -
Connectivity</TITLE></HEAD>\n" + "<BODY BGCOLOR =\"#FDF5E6\">\n");
out.println("</BODY>");
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
con = DriverManager.getConnection("jdbc:odbc:HomePage","","");
stmt = con.createStatement();
String sql = "Select * FROM THOMEPAGE";
rs = stmt.executeQuery(sql);
while(rs.next()){
out.println(rs.getString("WELCOME_MESSAGE"));
}
}
catch (ClassNotFoundException e) {
error = "Could not load database driver: " + e.getMessage();
out.println(error);
}
catch (SQLException e) {
error = "SQL Exception Caught: " + e.getMessage();
out.println(error);
}
finally {
try {
if (con != null) con.close();
}
catch (SQLException ignored) {}
}
}
}