This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

class or package not found with Tomcat?

 
Tom Barns
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I have the following two files,i put both in a directory "coreservlets" under classes directory.when i compile
i got errors saying that no class or package coreservlets found.
when i put both in classes directory ,everythings is ok.
thanks for your help.
//package coreservlet;
public class tobeimported
{
public String show()
{
return "show from tobeimported ";
}
}
//=============================================
//package coreservlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
//import coreservlets.tobeimported;
public class withImport extends HttpServlet {
public void service(HttpServletRequest req, HttpServletResponse res)
throws IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
tobeimported tbi = new tobeimported();
out.println(tbi.show());
}
}
 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is your file's name ?
is it tobeimported or not may be this can be the reason for your error .
 
Ajan Balakrishnan
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add your class file directory in your CLASSPATH. This will help your servlet locate the class no matter where you keep 'em.
One quick question, Are you keeping your servelts inside "coreservlets" package. If so FYI, you need to either prefix the package name during servlet's invocation or change your servlet's context path inside your server.xml file.

Ajan

[This message has been edited by Ajan Balakrishnan (edited February 23, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic