A Sample Web Application - VirtualTicket


Here is a sample web application VirtualTicket, developed with Tomcat. You could download the source code from here, unzip it, and copy the whole directory into $CATALINA/webapps/, here $CATALINA/ is the root directory you install Tomcat. Also you could click URL http://513web.csc.ncsu.edu/common/login.html to run it.

As you can see, this simple sample satisfies the standard layout of web application directory. In WEB-INF subdirectory there is a web.xml, the deployment descriptor. In the application directory, there are two files: an interface webpage login.html, which takes input from users, and forward it to validate.jsp. Dynamic executed, validate.jsp will tell servlets to connect the course Oracle database via JDBC API.

To run the example, launch Monitor Tomcat tool and start the service. Now you could visit the login page through http://localhost:8080/sample/login.htm (here I assume you unzip the source code in the subdirectory 'sample').

To test this application I created a table 'student' in the course Oracle database under my account. The initial instance of this table looks like:

NAME UNITYID ADDRESS STATUS
Yi Zhang yzhang12 Suite 243, Venture III Ph.D. Student
Student1 stu1 Suite 150, Venture II Masters Student

The user of VirtualTicket should already register in the database, whic­h is having a tuple in the 'student' table. Then he input his name as the username, according to the Name field of the tuple; and input UNITYID field as his password. The login.html will take over this input and call validate.jsp to verify the user's identification. If verified, validate.jsp will post the information of the 'student' table in the webpage. Otherwise, it prints 

Login ERROR: Unknown Users, or Unmatched UnityID 

To allow servlets use JDBC API, remember download and install some JDBC driver. Particularly, for the course Oracle database, go to http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html download Oracle9i Release 1 (9.0.1.4) & (9.0.1) drivers. Copy the driver you download (with the name class12.zip) into the subdirectory /WEB-INF/lib under your application directory, and rename it as class.jar.

( Actually after the course web server has been set up, I found the tech support stuff put this driver under /afs/eos/lockers/workspace/csc/csc513/001/common. You could get it directly. :-) )

                             Go Back To TA Page                                        


Course Webpage | JSP | Servlet | Apache Ant | Apache Jakarta Tomcat | FAQ | Contact Us