This example assumes that you have already managed to successfully build and run the minimal "Hello, Higgle" servlet as explained here. We can reuse the same niggletut web application context that we created for the helloniggle servlet. We can also reuse the same MinimalNiggleServlet.class that we created there.
Also, in terms of compiling our code, we can reuse verbatim the command that we used to compile the last example. On unix this was:
javac -classpath <libs>/niggle.jar:<libs>/servlet.jar *.java
and on Windows:
javac -classpath <libs>\niggle.jar;<libs>\servlet.jar *.java
where you replace <libs> with the directory where the libraries are located.
Now, one little detail is that we want to be sure that we have specified a location for our data (in this example, we actually do gather and store data!) to an appropriate, feasible location. Open up the the datasources.xml file. There, you will see a line that is:
<PROPERTY KEY="STORE" VALUE="/tmp/rolodex_data" />
Though many users will be able to get away with leaving the line as is, you should make sure that the VALUE attribute points to a location that is writable on your system. For example, on a Windows system, you might want to change the "/tmp" to "C:\windows\temp" or whatever is the appropriate location for temporary files.
After this, you need to make sure you have done the following steps:
$TOMCAT_HOME/webapps/niggletut/WEB-INF/lib
.Now we should be able to test the servlet. You should start (or restart, the case being) your server, be it Tomcat or whatever.
Now, if you have looked at the web.xml file, you might have noticed that
we added an extra servlet definition: minirolo
. So, at this point,
you should be able to open the URL:
http://localhost:8080/niggletut/servlet/minirolo
in your browser to run the mini-rolodex app. You can try to add an entry, edit an entry, etcetera. It is a primitive servlet, mind you, with very many possible improvements, but at least it does something!
At this point, you will probably want to read through the notes in which we dissect the various parts of the mini-rolodex example.