Packaging Servlets
Move the files to a subdirectory that 
matches the intended package name
We'll use the 
cwp
package. So, the class files need to go 
in a subdirectory called 
cwp
.
Insert a package statement in the class file
E.g., top of SimplerHelloWWW.java:
package cwp;
Set CLASSPATH to include top level 
development directory
Same as with any Java programming, but everyone 
forgets this step!
Include package name in URL
http://localhost/servlet/
cwp
.SimplerHelloWWW
15
Servlets
www.corewebprogramming.com
HelloWWW with ServletUtilities 
and Packages
package cwp;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SimplerHelloWWW extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println(
ServletUtilities.headWithTitle("Hello WWW")
+
"\n" +
"

Hello WWW

\n" +
"");
}
}
16
Servlets
www.corewebprogramming.com
8




  

Home

About Services Network Support FAQ Order Contact
 

Servlet Web Hosting

Our partners:Jsp Web Hosting Unlimited Web Hosting Cheapest Web Hosting  Java Web Hosting Web Templates Best Web Templates PHP Mysql Web Hosting Interland Web Hosting Cheap Web Hosting PHP Web Hosting Tomcat Web Hosting Quality Web Hosting Best Web Hosting  Mac Web Hosting 

Lunarwebhost.net  Business web hosting division of Vision Web Hosting Inc. All rights reserved