Integrating JBuilder4 Foundation with Apache Tomcat

By: J.D. Hildebrand

Abstract: A step-by-step procedure for integrating Tomcat 3.2.1 with JBuilder 4 Foundation, which allows servlets to be modified and debugged directly from the IDE. By Richard Lawson.

Server-side Java programming is increasingly becoming a mainstay of corporate IT departments as companies seek to open legacy systems to the internet. In addition, IT shops leverage server-side Java on the intranet by making corporate services available through a web-browser. Servlets and JSP provide a robust, cross-platform method of interacting with users both over the internet and corporate intranet.

Ok, you've heard that servlets are a good thing and you want to get started evaluating this technology. Of course, you may not have a large budget available for evaluation purposes. Well, I've got good news. You can create a great tool for servlet programming by combining JBuilder 4 foundation and the Tomcat servlet/JSP implementation. Both are available for free!

After you have convinced yourself that server-side Java is the way to go, you can upgrade to JBuilder 4 Professional or Enterprise which offer powerful wizards and plug-ins for servlet development. In addition, large enterprise applications will probably need a commercial servlet engine or full-blown J2EE application server. But for small projects or proof-of-concepts, the Tomcat engine with JBuilder 4 Foundation offers great value. See the following excellent article for setting up JBuilder 3.5 and Tomcat 3.1

Setting up Tomcat as a library

  • Download and install JBuilder 4 and Tomcat 3.2.1.
  • Start a new project in JBuilder 4 (see JBuilder documentation).
  • Choose Project Properties from the Project menu.
  • Choose the Required Libraries tab and click Add.
  • Click New.
  • Name your library.
  • Click Add to define library class files.
  • Add the following jar files and click OK.
  • Click OK to finish defining the library.
  • Select your new Tomcat library and hit Edit.
  • Click on the Source tab and then click Add.
  • Select the following source directory and hit OK. (This step makes the Tomcat source code available to the debugger.)
  • Hit OK again to finish defining the library.

Using Tomcat from within JBuilder 4

OK, now that you have the Tomcat library set up, you'll want to use it so you can run and debug servlets from within the JBuilder IDE. Once you have created a project, simply add the Tomcat library to your project by clicking the Add button from the Required Libraries tab of Project Properties. Select your library from the selection box.

Since our servlets are actually executed by the Tomcat servlet engine, we have to set the main class for our project to be Tomcat's main.

  • Click the Run tab of Project Properties.
  • Click the ... button.
  • Browse to the following class and select as main.
  • Our last step is to supply the VM with the TOMCAT_HOME property, which should be set to your Tomcat installation directory.
  • Verify installation by clicking Run. You should see Tomcat start up normally in the Tomcat pane at the bottom of the IDE.
  • You can set breakpoints from within your servlet and debug as normal by clicking on Debug.
  • Browse to your servlet by entering the appropriate context and servlet name http://localhost:8080/context/servlet.
  • See the Tomcat docs for how to set up contexts and servlet mappings.

Final notes

  • Be sure to set the output for your project to be the appropriate directory for your Web application (see below).
  • Make sure you have plenty of RAM, at least 256 Mb, or the debugger will crawl.
  • Enjoy !

The steps outlined in this document were tested on JBuilder 4 Foundation and Tomcat 3.2.1

By Richard Lawson, senior developer, Newark Electronics.


Server Response from: BDN9A

 
Copyright© 1994 - 2008 Embarcadero Technologies, Inc. All rights reserved. Contact Us   Site Map   Legal Notices   Privacy Policy   Report Software Piracy