|
APACHE TOMCAT
6 (6.0.28)
APACHE TOMCAT 7 INTERMEDIATE SERVLETS & JSP ADVANCED SERVLETS & JSP JAVASERVER FACES (JSF) JSF 1.x JSF 2.0 AJAX & GWT JAVASCRIPT & AJAX BASICS PROTOTYPE SCRIPTACULOUS JQUERY DOJO GWT 2.0 SPRING HIBERNATE & JPA JAVA 6 PROGRAMMING JAKARTA STRUTS EJB3 WEB SERVICES WITH AXIS2 SCWCD TUTORIALS IN CHINESE TUTORIALS IN JAPANESE
ABOUT THE INSTRUCTOR COURSE REVIEWS JSF 2.0, JSF 1.x, & MYFACES AJAX (w/ JQUERY, DOJO, EXT...) GWT 2.0 INTERMEDIATE SERVLETS & JSP SPRING FRAMEWORK HIBERNATE & JPA ADVANCED SERVLETS & JSP JAVA 6 PROGRAMMING JAKARTA STRUTS 1.x & STRUTS 2 SCWCD IPHONE PROGRAMMING CUSTOMIZED ON-SITE PUBLIC TRAINING SCHEDULE
|
Tutorial: Using Tomcat 6 with EclipseIt takes only a short time to download Eclipse and learn the bare bones basics of using it to build Web apps and deploy them to Tomcat. This time will be very quickly recouped by the savings in development, debugging, and deployment times. To get started with web apps in Eclipse, you only need to know a very small number of features. You can gradually learn the advanced capabilities at your leisure. This tutorial covers Tomcat 6, which supports the servlet 2.5 and JSP 2.1 specs. For coverage of Tomcat 7 (servlets 3.0 and JSP 2.2), please see the tutorial on Eclipse with Tomcat 7. Warning: JDK 1.6.0_21. Eclipse has a bug when used with JDK 1.6.0_21 that causes it to run out of memory and crash. If you use 1.6.0_21, please see the PermGen space error bug fix page. If you find these free tutorials helpful, we would appreciate it if you would link to us. Send corrections or feedback on any tutorial to hall@coreservlets.com. Executive SummaryHere is a quick summary of basic use; see the next sections for details on these core features.
For information on commercial Web hosting providers that support Tomcat, see the JSP hosting page. Unzip TomcatUnzip tomcat-6.0.28-preconfigured.zip into the location of your choice. I use the top level of the C drive, resulting in C:\apache-tomcat-6.0.28\. This preconfigured version of Tomcat has the following settings already in place. For details on customizing this configuration, please see the detailed configuration guide.
Alternatively, you can download any Tomcat 6 version from the Tomcat Web site and then copy context.xml, server.xml, and web.xml into install_dir/conf. These files are annotated with comments on what was done to them. Install and Start Eclipse
Go to http://www.eclipse.org/downloads/. Choose "Eclipse IDE for Java EE Developers", download, and unzip. There is no real installer, so unzipping it is all you need to do. I normally unzip into the top level of the C drive, resulting in C:\eclipse, but any location is fine. Start Eclipse by going to the "bin" folder and double-clicking on eclipse.exe. I usually make a shortcut on the desktop by R-clicking on eclipse.exe, selecting Copy, then going to the desktop, R-clicking, and doing Paste Shortcut.
After you start Eclipse, select "Workbench" as shown on the images to the right. I use Eclipse 3.6 (Helios), which is the latest Eclipse version as of July 2010. But, these directions apply equally to 3.5 (Galileo) and 3.4 (Ganymede). Tell Eclipse about Tomcat
First, start Eclipse and go to the Workbench as shown in the previous section.
Then, click on Servers tab at bottom. R-click, New, Server, Apache, Tomcat v6.0, navigate to folder, OK. You should now
see "Tomcat v6.0 Server at localhost" listed under the Servers tab at the bottom. Run Tomcat
Click on Servers tab at bottom. R-click on Tomcat v6.0, choose "Start".
Open http://localhost/ in a browser: you should see
an empty page showing a blank directory listing (but not
a 404 error). Eclipse incorrectly fails to copy the welcome pages when
it sets up Tomcat, so if you want the friendlier welcome page, go to
your-eclipse-workspace\.metadata and search for "ROOT". Copy all of the files from
C:\apache-tomcat-6.0.28\webapps\ROOT into the ROOT folder inside
your-eclipse-workspace\.metadata\...\ROOT.
Import and Test a Sample App
Grab
intro.zip and save it. Import it into Eclipse with
File, Import, General, Existing Projects, Select archive file.
Then click Browse and navigate to intro.zip.
Create a New Web App in Eclipse
Add Code to New Apps in Eclipse
Test New Apps in EclipseFollow same procedure as given in example above with "intro" app: Click on Servers tab at bottom. R-click on Tomcat v6.0 Server, choose "Add and Remove Projects". Choose app. Start Tomcat, or restart if already running. Open http://localhost/appName/ in browser. You must restart the server after adding a new project. To do so, R-click server and choose "Restart". For details on writing servlets, giving them custom URLs, using JSP, applying the MVC architecture, creating JSP custom tag libraries, and many other servlet and JSP topics, please see the servlet and JSP programming tutorial. Adjust Eclipse Preferences
One customization you almost always want to do is to suppress the unneeded warning re serialVersionUID on Serializable classes. The HttpServlet class is already Serializable, but nobody actually sends instances across the network or writes them to disk, and certainly almost nobody puts in a serialVersionUID field in servlets. But, if Eclipse marks every servlet with a warning, you get in the very bad habit of ignoring warnings. Most of the warnings are actually useful; this is a rare exception. So, go to Window, Preferences, Java, Compiler, Errors/Warnings, expand "Potential programming problems", and change "Serializable class without serialVersionUID" to "Ignore". Access the Servlet and JSP JavadocsThe single most useful reference for a servlet and JSP developer is the online API. So, you should add the servlet 2.5 API and the JSP 2.1 API to your bookmarks/favorites list. And, if you haven't already done so long ago, bookmark the Java SE 6 API. More Information
|
announcements
Too few developers for
Java 6 Programming: Feb 7-11 2011
Web App Development Feb 14-18 2011
Rich Internet Apps Feb 28-Mar 4 2011 March 7-11 2011 March 15-18 2011
Java EE with March 21-25 2011
RESTful & SOAP-based April 4-6 2011 Courses at CEU's Now Available
|
||||||||||||||||
| © 2010 coreservlets.com | Original design by TBIQ | Hosting from Kattare | ||||||||||||||||||






There are many customizations you can do in Eclipse. You can adjust the font size, colors,
indentation styles, import statement formats, and much much more. Go to Window, Preferences and browse around.