Win a copy of Getting started with Java on the Raspberry Pi this week in the Raspberry Pi forum!

Ken Rubin

Ranch Hand
+ Follow
since Mar 08, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ken Rubin

Thanks Tim! I have something to chew on for now. Happy holidays!
11 years ago
JSF
Hello,

I'm new to JSF. Could someone please point me in the right direction in how I may create a grid or table, which for a particular cell could have multiple items created dynamically, like buttons or links.
I see that there are tables, gridpanels and CSS Style sheets. If anyone could recommend a general approach, example or tutorial, it would be extremely helpful and greatly appreciated!

Thank you,

Ken
11 years ago
JSF
Hi Deepak,

"Meaning the variables do not appear under the "variables" view ? Is eclipse aware of the source files to the .class that you are debugging ?"

Eclipse is aware of my source and lets me step through it in debug mode.

The variables appear under the variable (expressions) view, but eclipse is indicating that a String like bio (shown below in code) cannot be resolved to a variable even though I executed the line.

I can see values for some variables like like 'this' and 'arg0'.

I built the code outside of Eclipse and imported the .war file into a project to debug.

Thanks,
Ken







package com.example.web;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class FormServlet extends HttpServlet {

protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
getServletContext().getRequestDispatcher("/WEB-INF/pages/form.jsp").forward(req, resp);
}

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String userName = request.getParameter("username");
String password = request.getParameter("password");
String bio = request.getParameter("bio");
String country = request.getParameter("country");
String subscribeForNewsletter = request.getParameter("newsletter");
String receiveMail = request.getParameter("receivemail");
String reveiveNotifications = request.getParameter("receivenotification");

response.setContentType("text/html");

PrintWriter writer = response.getWriter();
writer.write("<h2> You have entered following values </h2>");
writer.write("
");
writer.write("<table>");
startTableRow(writer);
addTableColumn(writer, "username");
addTableColumn(writer, userName);
closeTableRow(writer);

startTableRow(writer);
addTableColumn(writer, "password");
addTableColumn(writer, password);
closeTableRow(writer);

startTableRow(writer);
addTableColumn(writer, "Bio");
addTableColumn(writer, bio);
closeTableRow(writer);

startTableRow(writer);
addTableColumn(writer, "Country");
addTableColumn(writer, country);
closeTableRow(writer);

startTableRow(writer);
addTableColumn(writer, "Subscribe for news letter");
addTableColumn(writer, subscribeForNewsletter);
closeTableRow(writer);

startTableRow(writer);
addTableColumn(writer, "Receive mail from members");
addTableColumn(writer, receiveMail);
closeTableRow(writer);

startTableRow(writer);
addTableColumn(writer, "Receive notification");
addTableColumn(writer, reveiveNotifications);
closeTableRow(writer);

writer.write("</table>");

writer.close();

}

private static void startTableRow(PrintWriter writer) {
writer.write("<tr>");
}

private static void closeTableRow(PrintWriter writer) {
writer.write("</tr>");
}

private static void addTableColumn(PrintWriter writer, String value) {
writer.write("<td> "+ value + "</td>");
}


Hello,

I'm trying to debug a simple servlet on Eclipse running under Tomcat. I can get the Servlet to run and stop at the breakpoints, ( can see code) but I can't
see any of the program variable values.
javascript:emoticon('');

Eclipse is Java EE IDE for Web Developers Build id: 20100917-0705. Tomcat is 6.0.30.

I started Tomcat with the following file as recommended by a tutorial:http://www.wikijava.org/wiki/Debugging_a_servlet_with_tomcat_and_Eclipse_tutorial

set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
catalina.bat jpda start

The application is launched as http://localhost:8080/formexample/formServlet

The debug session is remote debug with connection type of standard socket attach and connection properties are localhost 8000.

If anyone can tell me why I can't see the variable values, I would be greatly appreciative!!

Thanks,
Ken

Hello,

I am setting up my Tomcat JNDI realm as:

<Realm className="org.apache.catalina.realm.JNDIRealm"
connectionURL="ldap://Au-dc1:389"
connectionName="CN=Ken Rubin,OU=Development,OU=Corporate,DC=mycompany,DC=com"
connectionPassword="mallory1"
userBase="OU=Development,OU=Corporate,DC=mycompany,DC=com"
userSearch="(sAMAccountName={0})"
userSubtree="true"
userRoleName="cn"
/>

I am only able to log onto Tomcat Manager if I set
userRoleName="cn", when as an attribute = "Ken Rubin". In web.xml for the Tomcat manager, I had to
set my name as a role. ie.

web.xml
<auth-constraint>
<role-name>Ken Rubin</role-name>
</auth-constraint>
</security-constraint>

<security-role>
<role-name>Ken Rubin</role-name>
</security-role>

My directory in LDAP is at "CN=Ken Rubin,OU=Development,OU=Corporate,DC=mycompany,DC=com".

I had wished to set userRoleName="memberOf" and return the roles for me, one these roles would be in my web.xml
instead of Ken Rubin. But I have been unable to do this.

One thing I noticed is that none of our company roles have any attributes listed under them.

Also I don't know how to get the logger to give me more possible information about why I am failing.

Any help would be greatly appreciated!

Thank you,
Ken

13 years ago
Hello,



Has anyone else had trouble starting Glass Fish in Netbeans 6.5.1? I got this when I initially tried to deploy HW for Webservices.



I get a message:

Authentication for GlassFish v2 failed with message Invalid user or password



It says that if the username or password is incorrect, you can change them via Tools|Servers. I have the admin user id and have tried to change the password many times, but still get the same message.



Any ideas?



Thanks,

Ken
Hello,

Can I call mysql_query() construct from a java program or something like it? (I want to use a LOAD INFILE ... from a text file to database and run it from java).

Thanks,

Ken
Thanks Ulf, now I know how to attack the problem.

Regards,

Ken
15 years ago
Thank you for responding so quickly!

When I do the following command

C:\ebayJavaSDK\SDKInstallDir\samples\JSDKToSoap\classes>java -classpath "C:\ebay
JavaSDK\SDKInstallDir\externalLib\axis-1_1;C:\ebayJavaSDK\SDKInstallDir\lib" com
.ebay.migration.CallJsdk

I get the exception for the CallJsdk:
Exception in thread "main" java.lang.NoClassDefFoundError: com/ebay/migration/CallJsdk

Not sure why.

Thanks,

Ken
15 years ago
Hello,

Asking about this topic is a bit embarassing

I'm try to run an executable with the following conditions:

My top level directory is C:\ebayJavaSDK\SDKInstallDir\samples\JSDKToSoap

The source code is one file at C:\ebayJavaSDK\SDKInstallDir\samples\JSDKToSoap\com\ebay\migration\CallJsdk.java. It has a package of com.ebay.migration.

The class file is at C:\ebayJavaSDK\SDKInstallDir\samples\JSDKToSoap\classes\com\ebay\migration.

When I try to run the code at the C:\ebayJavaSDK\SDKInstallDir\samples\JSDKToSoap\classes> directory by typing

java com.ebay.migration.CallJsdk, I get Exception in thread "main" java.lang.NoClassDefFoundError: com/ebay/sdk/SdkException.

or

java -classpath "C:\ebayJavaSDK\SDKInstallDir\samples\JSDKToSoap\classes" com.ebay.migration.CallJsdk - I get the same thing.

Can someone please give some assistance? I should know this.

Thanks,

Ken
15 years ago
Thanks for the response.

It took me some time to realize that I had a redundant class directory hierarchy where I was putting my changes, which wasn't
under WEB-INF, so any changes I made did not take. It's ok now.

Thanks again,

Ken
Dave, ( or who may see this)

Thank you again for the response! I changed the code, but I still get a class cast exception, but it doesn't make sense to me that it is happening. Here is the message and changed code:

org.apache.jasper.JasperException: com.mysql.jdbc.ResultSet cannot be cast to java.util.Vector
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.example.web.CoinSelect.doPost(Unknown Source)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

java.lang.ClassCastException: com.mysql.jdbc.ResultSet cannot be cast to java.util.Vector
org.apache.jsp.Result_jsp._jspService(Result_jsp.java:53)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.example.web.CoinSelect.doPost(Unknown Source)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

New Servlet Code:

package com.example.web;

import com.example.model.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.* ;


public class CoinSelect extends HttpServlet
{
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException,ServletException
{
Vector result = null;

String Series = request.getParameter("Series");
String Grade = request.getParameter("Grade");
String PriceRange = request.getParameter("PriceRange");

Testnew query = new Testnew();
result = query.getResult();

request.setAttribute("Coins",result);

RequestDispatcher view = request.getRequestDispatcher("Result.jsp");

view.forward(request,response);

}
}


Library code for Database:

package com.example.model;
import java.sql.* ;
import java.util.*;

public class Testnew
{
Vector return_value;

public static void main( String[] args )
{
Testnew query = new Testnew();
query.getResult();

}
public Vector getResult()
{
ResultSet rs;

rs=null;
try
{
Class.forName( "com.mysql.jdbc.Driver" ).newInstance();
try
{
//Connection con = DriverManager.getConnection( "jdbc:mysql://localhost/soup", "root", null );
Connection con = DriverManager.getConnection( "jdbc:mysql://localhost/coinsystem", "root", "mallory1" );
try
{
Statement statement = con.createStatement();

rs = statement.executeQuery("SELECT POP.ISSUEDATE,PRICE.ISSUEDATE,PRICE.VERYFINE,POP.VERYFINE FROM SEATED_DIME_PRICES PRICE, SEATED_DIME_POPULATION POP WHERE POP.ISSUEDATE = PRICE.ISSUEDATE");

while ( rs.next() )
{
System.out.println( rs.getString( 1 ) + " " + rs.getFloat(3));
return_value.add(rs.getString( 1 ) + " " + rs.getFloat(3));
System.out.println(return_value.get(0));

}
rs.close();
statement.close();
}
catch ( SQLException e )
{
System.out.println( "JDBC error: " + e );

}
finally
{
con.close();
return return_value;
}
}
catch( SQLException e )
{
System.out.println( "could not get JDBC connection: " + e );
}
}
catch( Exception e )
{
System.out.println( "could not load JDBC driver: " + e );
}
return return_value;

}
}
new JSP code:
<%@ pageimport="java.util.*"%>
<%@ page import= "java.sql.*"%>

<html>
<body>
<hi align="center">Coin Data JSP</h1>
<p>

<%
Vector rs = (Vector)request.getAttribute("Coins");

out.print( "<br>Coins: " + rs.get(0));

%>
</body>
</html>


Again any insights are greatly appreciated! I made sure to recompile everything and place it in deployment directories.

Best Wishes and Thanks,,

Ken
Hello,

I am creating my first Web application and am trying to access data from a
MySql database. When I do my query, I can see the data on the console, but it does not get to the JSP. Any assistance would be greatly appreciated!

The localhost log shows:

SEVERE: Servlet.service() for servlet jsp threw exception
java.sql.SQLException: Operation not allowed after ResultSet closed
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
at com.mysql.jdbc.ResultSet.checkClosed(ResultSet.java:666)
at com.mysql.jdbc.ResultSet.next(ResultSet.java:7274)
at org.apache.jsp.Result_jsp._jspService(Result_jsp.java:54)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:691)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:403)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at com.example.web.CoinSelect.doPost(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)
Aug 12, 2008 7:26:12 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet Ch3 Beer threw exception
java.sql.SQLException: Operation not allowed after ResultSet closed
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
at com.mysql.jdbc.ResultSet.checkClosed(ResultSet.java:666)
at com.mysql.jdbc.ResultSet.next(ResultSet.java:7274)
at org.apache.jsp.Result_jsp._jspService(Result_jsp.java:54)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:691)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:403)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at com.example.web.CoinSelect.doPost(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)

My code for accessing MySql is C:\web_components\coins\src\com\example\model\Testnew.java and is below:
package com.example.model;
import java.sql.* ;

public class Testnew
{
static ResultSet rs;

public static void main( String[] args )
{
Testnew query = new Testnew();
query.getResult();

}
public ResultSet getResult()
{
rs=null;
try
{
Class.forName( "com.mysql.jdbc.Driver" ).newInstance();
try
{
//Connection con = DriverManager.getConnection( "jdbc:mysql://localhost/soup", "root", null );
Connection con = DriverManager.getConnection( "jdbc:mysql://localhost/coinsystem", "root", "mallory1" );
try
{
Statement statement = con.createStatement();

rs = statement.executeQuery("SELECT POP.ISSUEDATE,PRICE.ISSUEDATE,PRICE.VERYFINE,POP.VERYFINE FROM SEATED_DIME_PRICES PRICE, SEATED_DIME_POPULATION POP WHERE POP.ISSUEDATE = PRICE.ISSUEDATE");

while ( rs.next() )
{
System.out.println( rs.getString( 1 ) + " " + rs.getFloat(3));
}
//rs.close();
//statement.close();
}
catch ( SQLException e )
{
System.out.println( "JDBC error: " + e );
}
finally
{
//con.close();
return rs;
}
}
catch( SQLException e )
{
System.out.println( "could not get JDBC connection: " + e );
}
}
catch( Exception e )
{
System.out.println( "could not load JDBC driver: " + e );
}
return rs;
}
}

My JSP at C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\coins\Result.jsp is:
<%@ pageimport="java.util.*"%>
<%@ page import= "java.sql.*"%>

<html>
<body>
<hi align="center">Coin Data JSP</h1>
<p>

<%
ResultSet rs = (ResultSet)request.getAttribute("Coins");
while ( rs.next() )
{
out.print( "<br>Coins: " + rs.getString( 1 ) + " " + rs.getFloat(3));
}
%>
</body>
</html>

My Servlet at C:\web_components\coins\src\com\example\web\CoinSelect.java
is:
package com.example.web;

import com.example.model.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.* ;


public class CoinSelect extends HttpServlet
{
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException,ServletException
{
ResultSet result = null;

String Series = request.getParameter("Series");
String Grade = request.getParameter("Grade");
String PriceRange = request.getParameter("PriceRange");

Testnew query = new Testnew();
result = query.getResult();

request.setAttribute("Coins",result);

RequestDispatcher view = request.getRequestDispatcher("Result.jsp");

view.forward(request,response);
}
}


The Browser showed the following:

org.apache.jasper.JasperException: Operation not allowed after ResultSet closed
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.example.web.CoinSelect.doPost(Unknown Source)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

javax.servlet.ServletException: Operation not allowed after ResultSet closed
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
org.apache.jsp.Result_jsp._jspService(Result_jsp.java:67)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.example.web.CoinSelect.doPost(Unknown Source)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

java.sql.SQLException: Operation not allowed after ResultSet closed
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
com.mysql.jdbc.ResultSet.checkClosed(ResultSet.java:666)
com.mysql.jdbc.ResultSet.next(ResultSet.java:7274)
org.apache.jsp.Result_jsp._jspService(Result_jsp.java:54)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.example.web.CoinSelect.doPost(Unknown Source)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

Again any help is greatly appreciated!!

Thank you,

Ken
David,

Thank you! This got me beyond this problem.

Best Wishes,

Ken
Hello,

I am attempting to write a simple Servlet. When I hit a submit button,
Tomcat tells me that it cannot find my Mysql driver.

The actual message is:

could not load JDBC driver ...ClassNotFoundException:com.mysql.jdbc.Driver

I have an actual driver (full path)
C:\mysql-connector-java-5.0.7\mysql-connector-java-5.0.7-bin.jar

The full path and file for my web.xml is shown below

Full Path- C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\coins\WEB-INF\web.xml is:

web.xml file-
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<!-- Define the controller servlet -->
<servlet>
<servlet-name>Ch3 Beer</servlet-name>
<servlet-class>com.example.web.CoinSelect</servlet-class>
</servlet>
<!-- END: Define the null servlet -->

<!-- The Struts controller mapping -->
<servlet-mapping>
<servlet-name>Ch3 Beer</servlet-name>
<url-pattern>/SelectCoin.do</url-pattern>
</servlet-mapping>
<!-- END: The Struts controller mapping -->
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/TestDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>


</web-app>

My context.xml file has it's full path and contents listed below:

Full path:
C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\context.xml

The file is:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- The contents of this file will be loaded for each web application -->
<Context>

<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>

<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="root" password="mallory1" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/javatest?autoReconnect=true"/>


</Context>

My classpath for the JDBC driver is:
C:\mysql-connector-java-5.0.7\mysql-connector-java-5.0.7-bin.jar

I can get data from the database using non Servlet programs.
Any insight would be greatly appreciated!

Thank you,

Ken