Hello,

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 * 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) {}
        }
    }





}



Reply via email to