Hi All,
I am new to this. I am trying to write a simple application in JSP to access MySQL on TomCat4.1.18.
I have downloaded the MySQL JDBC Driver from
I have copied the mm.mysql-2.0.14-bin.jar into 'lib' directory under my TomCat Default installation directory (E:/jakarta-tomcat-4.1.18/server/lib).
I have written this JSP :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Employees List </TITLE>
</HEAD>
<@ page import="java.sql.*" %>
<BODY>
<TABLE border=1 width=75%>
<TR><TH>Last Name</TH><TH>First Name</TH></TR>
<%
Connection conn = null;
Statement st = null;
ResultSet rs = null;
try
{
Class.forName("org.gjt.mm.mysql.Driver".newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost/cartapp"
st = conn.createStatement();
rs = st.executeQuery("select * from employees"
while(rs.next()){
%>
<TR><TD> <%= rs.getString("lname_txt" %> </TD>
<TD><%= rs.getString("fname_txt" %> </TR>
<%
}
%>
</TABLE>
<%
}catch(Exception ex) {
ex.printStackTrace();
%>
</TABLE>
Ooops, Something bad happened:
<%
}finally{
if(rs != null) rs.close();
if(st != null) st.close();
if(conn != null) conn.close();
}
%>
</BODY>
</HTML>
I have included the Context Path information in the 'server.xml' file.
<Context path="/JSPTestSamples" docBase="E:\JSPTestSamples" debug="1"
reloadable="true" crossContext="true"/>
When I execute in the browser, I get
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 10 in the jsp file: /employees_list.jsp
Generated servlet error:
[javac] Compiling 1 source file
E:\jakarta-tomcat-4.1.18\work\Standalone\localhost\JSPTestSamples\employees_list_jsp.java:57: cannot resolve symbol
symbol : class Connection
location: class org.apache.jsp.employees_list_jsp
Connection conn = null;
^
I AM UNABLE to RESOLVE....
Can any OF YOU tell me what's wrong??
I am new to this. I am trying to write a simple application in JSP to access MySQL on TomCat4.1.18.
I have downloaded the MySQL JDBC Driver from
I have copied the mm.mysql-2.0.14-bin.jar into 'lib' directory under my TomCat Default installation directory (E:/jakarta-tomcat-4.1.18/server/lib).
I have written this JSP :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Employees List </TITLE>
</HEAD>
<@ page import="java.sql.*" %>
<BODY>
<TABLE border=1 width=75%>
<TR><TH>Last Name</TH><TH>First Name</TH></TR>
<%
Connection conn = null;
Statement st = null;
ResultSet rs = null;
try
{
Class.forName("org.gjt.mm.mysql.Driver".newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost/cartapp"
st = conn.createStatement();
rs = st.executeQuery("select * from employees"
while(rs.next()){
%>
<TR><TD> <%= rs.getString("lname_txt" %> </TD>
<TD><%= rs.getString("fname_txt" %> </TR>
<%
}
%>
</TABLE>
<%
}catch(Exception ex) {
ex.printStackTrace();
%>
</TABLE>
Ooops, Something bad happened:
<%
}finally{
if(rs != null) rs.close();
if(st != null) st.close();
if(conn != null) conn.close();
}
%>
</BODY>
</HTML>
I have included the Context Path information in the 'server.xml' file.
<Context path="/JSPTestSamples" docBase="E:\JSPTestSamples" debug="1"
reloadable="true" crossContext="true"/>
When I execute in the browser, I get
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 10 in the jsp file: /employees_list.jsp
Generated servlet error:
[javac] Compiling 1 source file
E:\jakarta-tomcat-4.1.18\work\Standalone\localhost\JSPTestSamples\employees_list_jsp.java:57: cannot resolve symbol
symbol : class Connection
location: class org.apache.jsp.employees_list_jsp
Connection conn = null;
^
I AM UNABLE to RESOLVE....
Can any OF YOU tell me what's wrong??