The application wizard creates a new source tree for a simple Enhydra Web application. When you run it you specify the name of the application you wish to create. This application serves two purposes: it is an example program so that developers can test-drive Enhydra easily, and it is a good base on which to build projects. New developers are recommended to start a project by running the Application Wizard, then add and rename files as needed. This will ensure, among other things, that the Makefile system is started correctly.
Note that we are currently in the process of fitting a GUI onto this component. Please subscribe to the enhydra-announce mailing list to be notified when the GUI is released.
Running the Application Wizard will create a new directory in your current working directory, so first move to the location you want to create the source tree for your new application:
1.
cd <location-for-application>
The command to execute is "newapp", in the bin directory in your Enhydra installation. If the bin directory has been added to your PATH environment variable, you may simply type:
2a.
newapp <name>
otherwise you must type
2b.
/usr/local/enhydra/bin/newapp <name>
where /usr/local/enhydra is replaced with the directory you chose to install Enhydra in, and <name> is replaced with the name of the application you want to create. Throughout the rest of this document <name> will be used to represent your application name, please replace with whatever name you used. (Note: you may use uppercase letters in the name if you wish; when used as a Java package name the first letter will be lowercase, and when used as a Java class name the first letter will be uppercase, in all other cases it will be used as entered.)
An entire source tree will be created, in the directory <name>. Next we must compile the application:
3.
cd <name>
4.
make
This should compile your new application, placing the results (a jar file and a config file) in the directory output. If the make fails immediately, it is probably because of a version problem, i.e. you have a different version of the JDK installed than was expected. To fix this type of problem, edit the file config.mk. See the file lib/stdrules.mk in your Enhydra installation for a list of the various variables you can override.
Once your application is compiled, it is ready to run. A simple Enhydra Multiserver config file is created for you, so you can run the application right away:
5.
cd output
6.
./start
Now the application should be running on port 9000. If the Multiserver complains that it cannot open port 9000 you probably have another instance of the Multiserver running and using that port. This could be because you left one of your processes running/suspended, in which case you should find it and kill it (control-c or delete). Or this could be because another user on the system is using port 9000, in which case you must edit the file multiserver.conf and change 9000 to some other number (If you are not the root user you must use a port number greater than 1000.).
Once the application is running, use a Web browser to connect to it.
7. Go to the url: http://localhost:9000/
You should see "Welcome to <name>..." and the current date and time. Hit the reload button and watch the time update. The time is a sample of dynamic HTML: it could be replaced with anything you can access or compute in Java.
Clicking on the link "Sample redirect back to here" sends the browser to a special page that always responds with a redirect request back to the main page. Sometimes this occurs so quickly you may not notice anything happening. Redirects are very useful when you are building a Web application.
Congratulations! You have just created a Web application using Enhydra! We recommend you take some time to examine the make files, the Java code, and the html files. Familiarizing yourself with a simple clear-cut example will make it much easier to understand the source code to the two demo applications DemoCart and DemoApp. They are good examples of advanced uses of the Enhydra Application Framework.
If you want to try your application in another server, go to the top of the tree and type "make". This will ensure it is up to date and will rebuild the jar file output/lib/<name>.jar (you can type "make jar" to just build the jar file).
Your application is a servlet, so the server will need to support servlets. In Apache, for example, you should add the JServ servlet runner module. Add a servlet to your server (see the documentation for your server for instructions on how to do this). You will need to supply the following three pieces of information:
.jar
and enhydra.jar
(in /lib
in your Enhydra installation). org.enhydra.Servlet
confFile=/......./<name>.conf
"
(replace with the full path to the config file for your application, in the
output directory). Adding a servlet is very server-specific, please see your server's documentation.
Copyright 1997-1999 Lutris Technologies, Inc.
All rights reserved.