Web and Database Development Environment JSP Example

Please go through the HTML Example before doing this example.

NOTE: if you do not have a tomcat6 or tomcat7 directory, your account has NOT been configured for jsp and this tutorial will not be applicable.

Create a sample jsp file

JSP files can ONLY go in the tomcat6 or tomcat7 sub-directory of your web development directory.

  1. Go to the tomcat7 sub-directory of your web development directory and list the contents of the directory:

    [username@l-lnx101 username]$ cd /webdev/user/username/tomcat7
    [username@l-lnx101 tomcat7]$ ls
    auth.jsp           login.jsp           QueryServlet_psql.html
    EmpQuery.jsp       protectedPage.jsp   receivingPage.jsp
    EmpQuery_psql.jsp  QueryJSP.html       sample.html
    HelloWorld.jsp     QueryJSP_psql.html  sendingPage.jsp
    index.jsp          QueryJSP_psql.jsp   validateLogin.jsp
    JdbcQuery.jsp      QueryServlet.html   WEB-INF

  2. There are numerous examples here for you to look at and modify. If you go to http://webdev.cs.uiowa.edu/username-tomcat7/ it will load index.jsp by default.


  1. How do I compile my servlets so they will run?
    You need to have the servlet-api.jar file in your classpath. You may also need the jdbc driver as well if you are doing database work. The servlet-api.jar file is in /var/tomcat/apache-tomcat-7/lib/servlet-api.jar. The file mysql-connector-java-5.1.7-bin.jar is in the same directory.
  2. I tried to go to http://webdev.cs.uiowa.edu/~username/tomcat7/ and I got a Forbidden message.
    You need to go to http://webdev.cs.uiowa.edu/username-tomcat7/ to access jsp/servlet files.
  3. What's the difference between the tomcat6 and tomcat7 directories?
    The files in tomcat6 are served by an instance of the Tomcat 6 servlet container. The files in tomcat7 are served by an instance of the Tomcat 7 servlet container.