[EMAIL PROTECTED] wrote:

> Hello,
>
> Please note:  This email was submitted twice because of an error in the SQL
> statement in the first email.
>
> I am having a problem instaniating a Javabean from a Servlet.  When compiling
> the Servlet the following error occurs:  'cannot resolve symbol: Linkbean
> linkbean = new LinkBean();' I have run this servlet before instaniating the
> bean in the same manner with Weblogic.  Any help as to where to but bean
> class files, and why this error is occuring with Tomcat is greatly
> appreciated.  For convenience I have attached the source code for the
> Servlet.
>
> Thanks,
> 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 GetBean extends HttpServlet {
>
>   public void init(ServletConfig config) throws ServletException {
>     super.init(config);
>   }
>
>   public void doGet(HttpServletRequest request, HttpServletResponse response) throws 
>ServletException, IOException {
>
>       response.setContentType("text/html");
>
>       PrintWriter out = response.getWriter();
>       Connection con = null;
>       Statement stmt = null;
>       ResultSet rs = null;
>       String error = null;
>
>     try {
>
>     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
>     con = DriverManager.getConnection("jdbc:odbc:LINKS","","");
>     stmt = con.createStatement();
>     String sql = "Select * from Links";
>     rs = stmt.executeQuery(sql);
>
>       while(rs.next()){
>
>       LinkBean linkbean = new LinkBean();
>       linkbean.setValue(rs.getString("VALUE"));
>       linkbean.setNavText(rs.getString("NAVIGATION_TEXT"));
>
>       request.setAttribute("linkbean",linkbean);
>       RequestDispatcher dispatcher = 
>request.getRequestDispatcher("/jsp/Welcome.jsp");
>       dispatcher.forward(request, response);
>
>       }
>     }
>
>     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) {}
>         }
>     }
>
> }

the following is my suggestion :-)

* when you compile your Servlet code,  LinkBean need to be in CLASSPATH
* when you run        your Servlet code,  LinkBean need to be in:
      if(LinkBean is a unpacked class){
          - WEB-INF/classes(together will your Servlet class)
          - $CATALINA_HOME/classes
          - $CATALINA_HOME/common/classes
     }
     else if(LinkBean is in a packed jar){
          - WEB-INF/lib
         - $CATALINA_HOME/lib
         - $CATALINA_HOME/common/lib
    }



Bo
Sept.22, 2001



Reply via email to