Run Time Error .. Pls help .. Urgent

Discussions

Web tier: servlets, JSP, Web frameworks: Run Time Error .. Pls help .. Urgent

  1. Run Time Error .. Pls help .. Urgent (3 messages)

    Hello Friends

    I have a problem to connect the JSP Page with database. My bean class is working when i check it as stand alone application. when i include it with the jsp it gives the listed error message. i cant able to contineue my project with this. please help to figure out the problem.


    yours

    arumugam


    Bean Coding :

    import java.sql.*;
    import java.io.*;
    import java.util.Vector;

    public class OnlineShop {

    public Connection con=null;
    public Statement st=null;
    public ResultSet rs=null;

    public OnlineShop() { }

    public Vector Categories() throws ClassNotFoundException,SQLException{

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con =DriverManager.getConnection("jdbc:odbc:Test");
    st = con.createStatement();
    rs = st.executeQuery("Select Description from Products");
    Vector v = new Vector();
    while(rs.next())
    {
    String s = rs.getString(1);
    v.add(s);
    }
    String[] sa = new String[v.size()];
    for(int i=0;i<v.size();++i)
    {
    sa[i]=(String)v.elementAt(i);
    }
    con.close();
    return v;

    }
    }

    JSP Coding


    <%@ page language="java" import="OnlineShop,java.util.Vector" %>
    <jsp:useBean id="sb" class="OnlineShop" scope = "application" />

    <%
    Vector v = new Vector();
    v = sb.Categories();
    %>

    <html>
    <body>
    <center > calculators </center>
    <% for(int i=0;i<v.size();i++) { %>
    <table border="1">
    <tr>
    <td>
    <%=v.elementAt(i); %>
    </td>
    </tr>
    <% } %>
    </table>

    </body>
    </html>



    Error Message :

    Error during JSP page processing
    java.lang.NoSuchMethodError: java.util.Vector: method add(Ljava/lang/Object;)Z not found
    at OnlineShop.Categories(Compiled Code)
    at pagecompile.jsp._Calculator._jspService(_Calculator.java:99)
    at com.sun.server.http.pagecompile.jsp.runtime.HttpJspBase.service(HttpJspBase.java:87)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
    at com.sun.server.http.pagecompile.jsp.runtime.JspServlet.runServlet(JspServlet.java:469)
    at com.sun.server.http.pagecompile.jsp.runtime.JspServlet.processJspPage(JspServlet.java:259)
    at com.sun.server.http.pagecompile.jsp.runtime.JspServlet.service(JspServlet.java:97)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
    at com.sun.server.ServletState.callService(ServletState.java:226)
    at com.sun.server.ServletManager.callServletService(ServletManager.java:936)
    at com.sun.server.ProcessingState.invokeTargetServlet(ProcessingState.java:423)
    at com.sun.server.http.HttpProcessingState.execute(HttpProcessingState.java:79)
    at com.sun.server.http.stages.Runner.process(Runner.java:79)
    at com.sun.server.ProcessingSupport.process(Compiled Code)
    at com.sun.server.Service.process(Service.java:204)
    at com.sun.server.http.HttpServiceHandler.handleRequest(HttpServiceHandler.java:374)
    at com.sun.server.http.HttpServiceHandler.handleRequest(Compiled Code)
    at com.sun.server.HandlerThread.run(Compiled Code)

  2. Run Time Error .. Pls help .. Urgent[ Go to top ]

    chk ur server classpath.
  3. try

    v.addElement(s);

    instead of

    v.add(s);

    hope this helps.

  4. v.addElement(s) works fine. thanks for ur kind help

    arumugam