You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Purcell, Scott" <sp...@ltcgroup.com> on 2001/04/16 21:04:29 UTC

Package Q

Hello,
I am running the tomcat web server and I am working on Servlets. My install
is on
D:\tomcat\jakarta-tomcat-3.2.2b2
I am working on packages from Suns book, and have had success with creating
a folder called coreservlets under the following path:
D:\tomcat\jakarta-tomcat-3.2.2b2\webapps\ROOT\WEB-INF\classes\coreservlets
and have created some .java files there and have compiled. So I am competent
with my CLASSPATH settings. 

My question:
Now the book is calling (on page 33) two .java files. One calling the other.
The book stated to put both .java files into the coreservlets folder but
does not tell me how to compile this. So I try to compile as if it were a
normal .java file, but the calling file does not find the other file.
eg.
These two files are both sitting in the coreservlets folder, but I get
errors (as if I doesn't see the ServletUtilities.java file);
### file 1
package coreservlets;

import javax.servlet.*;
import javax.servlet.http.*;

public class ServletUtilities {
    public static final String DOCTYPE = "<!DOCTYPE HTML PUBLIC
\"=//W3C//DTD HTML 4.0 " + "Transitional/EN\">";

    public static String headWithTitle(String title) {
        return (DOCTYPE + "\n" +
                "<html>\n" +
                "<head></title>" + title + "</title></head>\n");
    }
}
##### file 2
package coreservlets;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloWWW3 extends HttpServlet {
    public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
        throws ServletException, IOException {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println(ServletUtilities.headWithTitle("HelloWWWW") +
                    "<body bgcolor=\"red\">\n" +
                    "<h1>Hello WWW Red</h1>\n" +
                    "</body></html>");
    }
}

But when I compile I get the following error:
 -d
D:\tomcat\jakarta-tomcat-3.2.2b2\webapps\ROOT\WEB-INF\classes\coreservlets
elloWWW3.java
HelloWWW3.java:13: cannot resolve symbol
symbol  : variable ServletUtilities
location: class coreservlets.HelloWWW3
        out.println(ServletUtilities.headWithTitle("HelloWWWW") +
                    ^
1 error

So that tells me it cannot find the ServletUtilities file?

Could someone try and get me through this?

Thanks
Scott