ok - shot in the dark -
you say your class is called HtmlSqlResult
but you import:
HtmlSQLResult; (SQL all in upper case)
could this be the problem?
otherwise I'm stumped : (
cheers,
Paul
> -----Original Message-----
> From: A.L. [mailto:[EMAIL PROTECTED]]
> Sent: 06 August 2001 17:21
> To: [EMAIL PROTECTED]
> Subject: RE: Servlet Uses Another Class
>
>
> Paul,
> i appreciate your help. I haven't been able to get
> any servlet I have created to work which imports
> another clas for some reason. SO what I am currently
> trying to do is use an example from the Oreilly
> Servlet book. Unfortunately the book doesn't have a
> solution to the problem I am experiencing. The
> previous use of the terms myClass and Myservlet were
> used to simplify things. The real java files are
> Calendar.java and HtmlSqlResult.java. Calendar is the
> Servlet which creates an instance of HtmlSqlResult.
>
>
> HtmlSqlResult is compiling fine. I currenlty have it
> in the same directory as Calendar.java. Now when I
> try to compile Calendar.java I get the following
> error:
>
> C:\work\jt\tomcat\webapps\jd\WEB-INF\classes>javac
> Calendar.java
> Calendar.java:8: cannot resolve symbol
> symbol: class HtmlSQLResult
> import HtmlSQLResult;
> ^
> Calendar.java:59: cannot resolve symbol
> symbol : class HtmlSQLResult
> location: class Calendar
> HtmlSQLResult result;
> ^
> 2 errors
>
>
>
> Here is the code for Calendar.java :
>
>
>
> import HtmlSQLResult;
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.io.*;
> import java.sql.*;
> /**
> *
> * @author alieberman
> * @version
> */
> public class Calendar extends HttpServlet {
> private Connection con = null;
> public void init() throws ServletException {
> try
> {
>
> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> con =
> DriverManager.getConnection("jdbc:odbc:calendar");
> }
> catch (ClassNotFoundException e){
> throw new UnavailableException("Couldn't load
> database driver");
> }
>
> catch (SQLException e) {
> throw new UnavailableException("Couldn't Get
> db Connection");
> }
> }
>
> /** Destroys the servlet.
> */
> public void destroy() {
> try {
> if (con!=null) con.close();
> }
> catch (SQLException ignored) {}
>
> }
>
> /** Processes requests for both HTTP
> <code>GET</code> and <code>POST</code> methods.
> * @param request servlet request
> * @param response servlet response
> */
> protected void processRequest(HttpServletRequest
> request, HttpServletResponse response)
> throws ServletException, java.io.IOException {
> response.setContentType("text/html");
> java.io.PrintWriter out =
> response.getWriter();
>
> out.println("<html>");
> out.println("<head>");
> out.println("<title>Calendar</title>");
> out.println("</head>");
> out.println("<body>");
> HtmlSQLResult result;
> out.println("</body>");
> out.println("</html>");
>
> out.close();
> }
>
> /** Handles the HTTP <code>GET</code> method.
> * @param request servlet request
> * @param response servlet response
> */
> protected void doGet(HttpServletRequest request,
> HttpServletResponse response)
> throws ServletException, java.io.IOException {
> processRequest(request, response);
> }
>
> /** Handles the HTTP <code>POST</code> method.
> * @param request servlet request
> * @param response servlet response
> */
> protected void doPost(HttpServletRequest request,
> HttpServletResponse response)
> throws ServletException, java.io.IOException {
> processRequest(request, response);
> }
>
> /** Returns a short description of the servlet.
> */
> public String getServletInfo() {
> return "Short description";
> }
>
> }
>
>
>
>
>
>
>
>
>
>
> --- Paul Foxton <[EMAIL PROTECTED]> wrote:
> > hmmm.
> >
> > where does the error occurr? the first time you
> > actually use the class in
> > the servlet and after the import statement?
> >
> > if so it seems you must be importing it ok, so the
> > there's another problem.
> >
> > If you get the error actually on the import
> > statement then perhaps you have
> > the name of the class wrong in your servlet?
> >
> > if you post the code and the error message, might be
> > able to help more....
> >
> > cheers,
> >
> > Paul
> >
> >
> > > -----Original Message-----
> > > From: A.L. [mailto:[EMAIL PROTECTED]]
> > > Sent: 06 August 2001 16:52
> > > To: [EMAIL PROTECTED]
> > > Subject: RE: Servlet Uses Another Class
> > >
> > >
> > > I have tried simply importing the class MyClass,
> > and
> > > not creating it as a package. Nevertheless I get
> > the
> > > Cannot Resolve Symbol error.
> > >
> > > Both the MyClass and the MyServlet class files are
> > in
> > > the same directory. In my servlet
> > > --- Paul Foxton <[EMAIL PROTECTED]> wrote:
> > > > did you import the class explicitly in your
> > servlet?
> > > >
> > > > eg: (without a package)
> > > >
> > > > import MyClass;
> > > >
> > > > public class MyServlet extends HttpServlet
> > throws
> > > > ServletEsception
> > > > IOException
> > > > {
> > > > MyClass instanceOfMyClass;
> > > > instanceOfMyClass = new MyClass();
> > > >
> > > > etc.
> > > >
> > > > to import the class in the package:
> > > >
> > > > import com.mypackage.MyClass
> > > >
> > > > cheers,
> > > >
> > > > Paul
> > > >
> > > > > -----Original Message-----
> > > > > From: A.L. [mailto:[EMAIL PROTECTED]]
> > > > > Sent: 06 August 2001 16:04
> > > > > To: [EMAIL PROTECTED]
> > > > > Subject: Servlet Uses Another Class
> > > > >
> > > > >
> > > > > I am unable to create and run a servlet which
> > uses
> > > > > another class which I have create. How may
> > this
> > > > be
> > > > > achieved.
> > > > >
> > > > > Here is my problem:
> > > > > I have a servlet (myServlet), which needs to
> > > > create an
> > > > > instance of a class I designed. I assumed
> > that
> > > > > putting the myClass.class file in the
> > > > WEB-INF/classes/
> > > > > directory along with the myServlet.class file
> > > > would
> > > > > take care of this. Yet I get a "cannot resolve
> > > > symbol
> > > > > error".
> > > > > My next idea was to put the class file in a
> > > > directory
> > > > > titled myPackage. In the myServlet class I
> > put
> > > > the
> > > > > proper import myPackage.*; and in the
> > > > myClass.class
> > > > > file I put the code package myPackage.
> > > > >
> > > > > I assumed that perhaps turning the class file
> > into
> > > > a
> > > > > package would help. But now I get an error
> > > > stating:
> > > > > package myPackage does not exist.
> > > > >
> > > > >
> > > > > My question is how can I get the servlet to
> > find
> > > > the
> > > > > class I created so that it may create an
> > instance
> > > > of
> > > > > the class?
> > > > >
> > > > >
> > > > >
> > __________________________________________________
> > > > > Do You Yahoo!?
> > > > > Make international calls for as low as
> > $.04/minute
> > > > with
> > > > > Yahoo! Messenger
> > > > > http://phonecard.yahoo.com/
> > > > >
> > >
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Make international calls for as low as $.04/minute
> > with
> > > Yahoo! Messenger
> > > http://phonecard.yahoo.com/
> > >
>
>
> __________________________________________________
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with
> Yahoo! Messenger
> http://phonecard.yahoo.com/
>