Until now, we have only run our super servlet on its own, outside of the overall multiserver. This functionality is great for developers who want to be able to test applications without interfering with the main production web site, but we will want to add our application to that server at some point.
Enhydra makes this relatively easy to do: we add information about our application to the multiserver's configuration file, so that it can find the application. Then we use the multiserver's control panel to add our application to the production server under the URL of our choice. At that point, our application is available for all the world to see.
In order to accomplish this, we must start the multiserver once again, with the shell script $ENHYDRA/bin/multiserver. This makes the multiserver available on port 8001. Load the administration screen in your browser, and look at the list of available applications in the top-left corner.
Now we will copy the application configuration file—but not the application itself—named output/conf/myproject.conf and copy it to the global multiserver directory, $ENHYDRA/apps. Then edit $ENHYDRA/apps/myproject.conf, changing the value of Server.ClassPath. There are already two possible values for Server.ClassPath in myproject.conf: one for running the application in standalone mode and another for running it under the multiserver. Comment out the (first) standalone value, and uncomment the (second) multiserver value.
Having done this, return to your web browser and click on the Add button (with a big + sign on it) in the multiserver control panel. We're going to add a new application, whose name (myproject) should be in the selection list. Choose a root URL for this application, and enter any text string you want for this application's group. Click on OK to add the application.
Now refresh the multiserver control panel. In the upper left-hand corner, you should see “myproject”, along with whatever other applications might currently be loaded. If you click on the myproject name, the right-hand side of the screen will fill with information about myproject.
We can test our FooPresentation object by changing the URL, replacing WelcomePresentation.po to FooPresentation.po. Sure enough, we see our simple Foo HTML output displayed in the browser.
We can remove our application from one or more ports or from the multiserver entirely using the web-based control panel. Finally, we can shut down the multiserver either using the control panel or by pressing Ctrl-C in the terminal window where we started it.
It is not inherently difficult to write servlets, but Enhydra offers much more than just servlets. In particular, they provide an environment that makes it easy to write and test servlets without having to run a full web server. Moreover, the super servlets that Enhydra provides can be easier to work with than regular servlets, especially since we can avoid having to deal with threading issues and writing a new overall handler application for each page.
There are, of course, some drawbacks. Enhydra, like most Java programs, requires a fair amount of patience when setting CLASSPATH. (Although to the credit of Lutris, removing my own CLASSPATH solved almost all of those problems.) And while Enhydra's automatically generated Makefiles dramatically reduce the amount of thought that you must put into creating a finished web application, Java programs always seem to require ten times as many files as their Perl and Python counterparts.
While super servlets are certainly an improvement over their nonsuper cousins, I always hesitate before jumping into a technology that deviates from a known, well-documented and mature standard—particularly when the Open Source community seems to be taking its time to rally around Enhydra in a major way. Finally, while it's true that Enhydra Enterprise is not yet a released product, the installation instructions and documentation leave something to be desired.
With all of these reservations, I easily can see myself using Enhydra for future Java development, instead of the plain, vanilla Jakarta-Tomcat that I have used in the past. The combination of XMLC and an integrated environment is quite attractive in many ways.
As I mentioned earlier, one of the reasons I am most excited about Enhydra Enterprise is its ability to connect to Sun's Enterprise JavaBeans. Over the next two months, we will look more closely at Enhydra, first investigating its DODS tool for mapping relational databases to Java objects. Then we will dip our toes into the world of EJB, demonstrating that just because we rely on open-source products doesn't mean that our tools are any less capable than proprietary programmers.
Reuven M. Lerner owns a small consulting firm specializing in web and internet technologies. He lives with his wife Shira and daughter Atara Margalit in Modi'in, Israel. You can reach him at email@example.com or on the ATF home page, www.lerner.co.il/atf.
Reuven M. Lerner, Linux Journal Senior Columnist, a longtime Web developer, consultant and trainer, is completing his PhD in learning sciences at Northwestern University.
- Great Scott! It's Version 13!
- Divx# Watch The Other Woman Full HD Online Streaming Viooz
- Numerical Python
- NSA: Linux Journal is an "extremist forum" and its readers get flagged for extra surveillance
- Adminer—Better Than Awesome!
- Tech Tip: Really Simple HTTP Server with Python
- RSS Feeds
- Linux Systems Administrator
- It Actually Is Rocket Science
- Senior Perl Developer