Table of Contents
Using The Student Web Server
You can use your account in the department lab to serve web pages and servlets. Simply log in to the lab and put your files in the public_html folder in your home directory. You can access your page at: http://students.cs.ndsu.nodak.edu/~username/. The server uses the public_html folder in your home directory, so any changes made to that will affect your webpage.
Please see webpage for more details.
JSP and Servlets
JSP
To use JSP, simply drop your .jsp file into your public_html directory. The web server will forward any requests for JSP files along to Tomcat for processing.
Servlets
Servlets are slightly more complicated. To use a servlet on your webpage, you need:
- Your compiled servlet class
- Your web.xml file
Your servlet resides in /home/<user>/public_html/WEB-INF/. The web.xml file resides in this folder and defines your servlet. You will need a classes subfolder for any java classes you need for running the servlet.
Here is an example web.xml file:
<web-app> <servlet> <servlet-name>ServletName</servlet-name> <servlet-class>ServletClass</servlet-class> </servlet> <servlet-mapping> <servlet-name>ServletName</servlet-name> <url-pattern>/servlet/ServletName</url-pattern> </servlet-mapping> </web-app>
The file is pretty straightforward XML and contains the basic definition of your servlet. This file is read by Tomcat so it knows where your servlet is and how people will refer to it. Replace the name and class with your own servlet information. The url-pattern attribute is used to define how users will access your servlet. In the example above, when the user goes to http://students.cs.ndsu.nodak.edu/~username/servlet/ServletName the server processes the request and knows the user is requesting the servlet.
In our current server configuration, servlets NEED to be at the /~username/servlet/ url or else Tomcat may not get the request for it.
You can check out example JSP and servlets at: http://students.cs.ndsu.nodak.edu/examples/
Servlet Directory Structure
/home/username/public_html/ <this is your webpage> /home/username/public_html/WEB-INF/ <your servlet base folder> /home/username/public_html/WEB-INF/web.xml <definition of your servlet> /home/username/public_html/WEB-INF/classes/* <the compiled classes of your servlet>