The reason is that if the JVM trys to load a class not in a package, it looks in the "current" directory. In the servlet environment you have no control over the "current" directory, therefore ALL classes used in servlets MUST be in packages to avoid strange errors.
posted 11 years ago
There are environments wherein packageless servlets work (combination of certain appserver implementation/version and certain JVM implementation/version), but you should never make your application dependent on that. Put classes in packages, period. Only then the other classes can import them.
this is supposed to be a surprise, but it smells like a tiny ad: