|
APACHE TOMCAT
6
APACHE TOMCAT 5.5 INTERMEDIATE SERVLETS & JSP ADVANCED SERVLETS & JSP SCWCD JAKARTA STRUTS JAVASERVER FACES (JSF) AJAX & GWT (Google Web Toolkit) Tutorial PROTOTYPE SCRIPTACULOUS JAVA 5 & 6 PROGRAMMING TUTORIALS IN CHINESE TUTORIALS IN JAPANESE
ABOUT THE INSTRUCTOR COURSE REVIEWS JSF & APACHE MYFACES AJAX & GWT (Google Web Toolkit) Training INTERMEDIATE SERVLETS & JSP ADVANCED SERVLETS & JSP SCWCD JAKARTA STRUTS JAVA 5 & 6 PROGRAMMING CUSTOMIZED ON-SITE PUBLIC COURSE SCHEDULE
|
table of contents• Executive Summary• Verify that you can start the server. • Check that you can access your own HTML & JSP pages. • Set up your development environment. • Try compiling and deploying servlets. • More Information Testing Server SetupFor Manual Tomcat Installation (No IDE)Executive SummaryAfter you set up Tomcat, make sure you can run it and that you can execute HTML pages, JSP pages, and servlets. Here is a quick summary; see the next sections for details.
1. Verify That the Server Can StartBefore trying your own servlets or JSP pages, you should make sure that the server is installed and configured properly. For Tomcat, click on install_dir/bin/startup.bat (or execute install_dir/bin/startup.sh on Unix/Linux). Next, enter the URL http://localhost/ in your browser and make sure you get the Tomcat welcome page, not an error message saying that the page could not be displayed or that the server could not be found. If you chose not to change the port number to 80 as described in the detailed configuration page, you will need to use a URL like http://localhost:8080/ that includes the port number. If this does not work, there are a couple of things to check:
To halt the server, double click on install_dir/bin/shutdown.bat. I recommend that you make shortcuts to (not copies of) the startup and shutdown scripts and place those shortcuts on the desktop or in your main development directory. If you put them on the desktop, you can assign keyboard shortcuts, which is convenient. 2. Try Some Simple HTML and JSP PagesAfter you have verified that the server is running, you should make sure that you can install and access simple HTML and JSP pages. This test, if successful, shows two important things. First, successfully accessing an HTML page shows that you understand which directories should hold HTML and JSP files, and what URLs correspond to them. Second, successfully accessing a new JSP page shows that the Java compiler (not just the Java virtual machine) is configured properly. Eventually, you will almost certainly want to create and use your own Web applications, but for initial testing many people prefer to use the default Web application. With Tomcat and the default Web application, you put HTML and JSP pages in install_dir/webapps/ROOT or install_dir/webapps/ROOT/somePath and access them with http://localhost/filename or http://localhost/somePath/filename. For your first tests, I suggest you simply take Hello.html and Hello.jsp and drop them into the appropriate locations. Right click on the link to download these two files to your system. If you download the files using Internet Explorer, be careful that it does not try to change the file extension, yielding Hello.htm instead of Hello.html. Note also that the preconfigured Tomcat version already contains all the test files, and has shortcuts from the development directory to the deployment locations. If you put the files in the top-level directory of the default Web application (i.e., in install_dir/webapps/ROOT), access them with the URLs http://localhost/Hello.html and http://localhost/Hello.jsp, respectively. If you put them in a subdirectory of install_dir/webapps/ROOT, use the URLs http://localhost/directoryName/Hello.html and http://localhost/directoryName/Hello.jsp, respectively. If you successfully started the server as
described above, but
neither the HTML file nor the JSP file works (e.g., you get File Not
Found--404--errors), you likely are using the wrong directory for the files. If the
HTML file works but the JSP file fails, you probably have incorrectly specified the
base JDK directory (i.e., with the 3. Compile and Test Some Simple ServletsOK, so your environment is all set. At least you think it is. It would be nice to confirm that hypothesis. Verifying this involves the following three steps:
Details on each step are given below. Test 1: A Servlet That Does Not Use PackagesThe first servlet to try is a basic one: no packages or utility (helper) classes. Rather than writing your own test servlet, you can just download HelloServlet.java into your development directory, compile it, and copy the .class file to install_dir/webapps/ROOT/WEB-INF/classes. Right-click on the link to download the file to your system. Note: in all versions of Apache Tomcat, the location for servlets in the default Web application is install_dir/webapps/ROOT/WEB-INF/classes. However, in some versions of Tomcat (including Tomcat 6.0.10), the system doesn't create the classes directory for you automatically. No problem: just create it yourself. (Remember that case matters: WEB-INF is upper case, classes is lower case.) Note that my preconfigured Apache Tomcat version already contains the classes directory and already has the sample servlets. If you get compilation errors, go back and check your
Test 2: A Servlet That Uses PackagesThe second servlet to try is one that uses packages but not utility classes. Again,
rather than writing your own test, you can download and install
HelloServlet2.java.
Since this servlet is in the Once you have placed the servlet in the proper directory, access it with the URL http://localhost/servlet/coreservlets.HelloServlet2. You should get a simple HTML page that says "Hello (2)". If the first test succeeded but this test failed, you probably either typed the URL wrong (e.g., used a slash instead of a dot after the package name) or put HelloServlet2.class in the wrong location (e.g., directly in install_dir/webapps/ROOT/WEB-INF/classes directory instead of in the coreservlets subdirectory). Test 3: A Servlet That Uses Packages and UtilitiesThe final servlet you should test to verify the configuration of
your server and development
environment is one that uses both packages and utility classes.
HelloServlet3.java
is a servlet in the If you get compilation errors such as "
Please don't send me email about unresolved symbol errors until you have confirmed that HelloServlet3.java and ServletUtilities.java are in a subdirectory called coreservlets, and that the directory above this is in the CLASSPATH. Once you compile HelloServlet3.java (which will automatically cause ServletUtilities.java to be compiled), copy (don't move!) the entire coreservlets subdirectory from your development location to install_dir/webapps/ROOT/WEB-INF/classes. Then, access the servlet with the URL http://localhost/servlet/coreservlets.HelloServlet3 (again, note that it is a dot, not a slash, between the package name and the servlet name). You should get a simple HTML page that says "Hello (3)". More InformationOnline documentation
|
announcements
The following public
Rich Internet Apps October 20-24, 2008
Web App Development October 13-17, 2008
Java Programming: August 18-22, 2008 Courses at CEU's Now Available
|
||||||
| © 2008 coreservlets.com | Original design by TBIQ Technologies | ||||||||


