Servlet SetUp on CSU Chico machines
If you desire to run your own WebServer (and I suggest you do for easier debugging), I will presume that you can set up your own machines (i.e., I will not give you directions for downloading and setting up the server). I do, however, suggest either using
- Tomcat (since that is what is used here)
Tomcat is used in Marty Hall's notes. Here is a page to help setup.
- the Application Server version provided with the J2EE download. This web server comes with a nice page to illustrate its use.
Whether you are local or offsite you should provide your servlet for grading on the machine here.
Below is the set up for users of the TomCat server already installed at CSUC on our Unix machines. Which you would access through accounts on the machine ect-unix.ecst.csuchico.edu which is also ect-sun.ecst.csuchico.edu which defaults to tiglon.ecst.csuchico.edu, IP address:
132.241.6.18
- Tell the system adminstrators here that you want permission to put servlets on our server. They will set you up in the necessary context. (You will need to already have an account there; if you don't - new accounts )
- Put your java servlet classes in the right place
- Under your public_html directory make a WEB-INF directory (note capitals). .
- Under your WEB-INF directory make a classes directory.
- your servlet classes and packages (correct directory placement) should be placed here
- Under your WEB-INF directory make a lib directory. This is then automatically in Tomcats CLASSPATH along with the JDK and SDK, etc
- any libraries that you intend to use you should jar up and put here (e.g., jar files for InstantDB database). The servlet server (lynx) is not the same as the one on your ect account (lynx is the ECST web server but tiglon is where your account is housed) so your CLASSPATH is not valid for servlets. All necessary classes that the servlet imports (other than standard JDK and SDK) should be jarred and put in the lib directory. (However, to compile your servlets you still should have /usr/java/lib/servlet.jar in your CLASSPATH)
- If you have a web application deployment descriptor (web.xml file) put it in the WEB-INF directory as well
- Under your public_html directory/subdirectories you can now put html pages that access your servlets. The html page should have all of the GUI stuff and should say where the servlet is (see 4). Remember that servlets are simply server-side applets. These html pages are what will access the servlet classes.
So, remember, these html files do not need to be in the WEB-INF directory; the WEB-INF directory is for the servlet classes.
- Important: The html code should have the path of your web page but rather than the WEB-INF directory, it should say servlet
Specifically, here is an example of a line that might be in your html file for a servlet class
where the java code is at public_html/WEB-INF/classes/MyServlet.class:
I also have the Register.html file in the my directory and Register.class in my servlet directory.