Dear all,

  I am having trouble debugging this bean code which is in my =
c:\tomcat\webapps\scjd\ShoppingCart  folder:

    package ShoppingCart;

    import java.sql.*;

    public class PersistentConnection11 {
      private static Connection cn;
      private static String url;
      private static boolean valid = false;

      public void setUrl(String url) {
        try {
          Class.forName("org.gjt.mm.mysql.Driver").newInstance();
       cn = DriverManager.getConnection(url);
        } catch (Exception e) {
          System.err.println("Error loading class");
          e.printStackTrace(System.err);
        }
      }

      public void shutDown() {
        try {
          cn.close();
        } catch (Exception e) {}
      }

      public static void reset() {
        try {
          cn.close();
          cn   = DriverManager.getConnection(url);
          valid = true;
        } catch (Exception e) {
          System.err.println("Unable to reset connection");
          e.printStackTrace();
        }
      }

      public boolean isValid() {return valid;}
    }

    When I run this bean through this .jsp file:

    <%-- Create the connection, if it does not yet exist --%>

    <jsp:useBean
         id="dbConnection"
         class="ShoppingCart.PersistentConnection11"
         scope="application"
    >

     <%-- If we are creating this bean now, initialize it --%>

     <jsp:setProperty
            name="dbConnection"
            property="url"
            value="jdbc:mysql://localhost/javaworks?javaworks&password=3Dguest"
     />

    </jsp:useBean>

    I encouter the following error. Please help me. What am I doing =
wrong here???
    Error: 500
    Location: /scjd/ShoppingCart/dbConnect.jsp
    Internal Servlet Error:

    javax.servlet.ServletException: ShoppingCart.PersistentConnection11at
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContext
    Impl.java:386)
at =
ShoppingCart._0002fShoppingCart_0002fdbConnect_0002ejspdbConnect_jsp_2._j=
spService(_0002fShoppingCart_0002fdbConnect_0002ejspdbConnect_jsp_2.java:=
99)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at =
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet=
.java:174)
at =
org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at =
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:5=
03)
at =
org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
at =
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(Ht=
tpConnectionHandler.java:160)
at =
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:=
338)
at java.lang.Thread.run(Unknown Source)

    Root cause:=20
java.lang.ClassCastException: ShoppingCart.PersistentConnection11
at =
ShoppingCart._0002fShoppingCart_0002fdbConnect_0002ejspdbConnect_jsp_2._j=
spService(_0002fShoppingCart_0002fdbConnect_0002ejspdbConnect_jsp_2.java:=
66)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at =
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet=
.java:174)
at =
org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at =
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:5=
03)
at =
org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
at =
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(Ht=
tpConnectionHandler.java:160)
at =
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:=
338)
at java.lang.Thread.run(Unknown Source)


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.231 / Virus Database: 112 - Release Date: 12/02/2001

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
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

Reply via email to