CIS 3344: Web API Activity

As of Monday March 16, 2020, this course has been converted to fully online. You will do your Lab Activity from home. To get a grade for a Lab Activity you must (between Sunday 11am and Monday 1pm):

In this Lab Activity, you will:


  1. Create a new NetBeans project and install this sample code into that new project using these enhanced installation instructions that are now necessary because the project has server side code (java/JSP).

    The enhanced installation instructions show you where you can find the two JAR files, but you can also download these two files from here (you just have to do this once for the semester). Please store these two files under the NetBeansProjects folder (so that you and I both know where to find them):

  2. Open up (under Web Pages) webAPIs/listUsersAPI_educational.jsp and run it. If you see a jumble of data on the page, it worked.
  3. BUT if you see a communications link error (which you will ALWAYS see from home), tunnel in following these instructions.
  4. So that you can see your JSON data nicely formatted in the browser, install JSON View for Chrome. Then, refresh your page and you should see the JSON data from the Web API formatted like this:
            dbError: "",
            webUserList: [
                    webUserId: "1",
                    userEmail: "sallyk",
                    userPassword: "pw",
                    image: "",
                    birthday: "01/01/1980",
                    membershipFee: "",
                    errorMsg: ""
                    webUserId: "2",

    Worth 3 points: for installing the sample code, installing the JSON View Chrome plugin, and locally running a Web API (JSP page) that displays all of SALLY'S web_user data in JSON format.

  5. Under "Source Packages", open up dbUtils/DbConn. This wrapper class for java.sql.Connection opens up your particular database (because you supply your own database credentials). Edit the DB credentials so that it opens up YOUR database, not mine. The database password is the crazy auto-generated password that you used last week - not your NetAccess password.
        public DbConn() {
            String dbAndPass = "SP20_3344_tua12345?user=tua12345&password=goofyAutoGeneratedPw";
  6. After refreshing the Web API, you should see your own data instead of mine -- UNLESS your web_user table was not created exactly as specified last week. If you got an error, change your database design using MySQL Workbench (do not change the sample code).

    Worth 3 more points (6/9 so far): for redirecting the sample Web API to pull data from your web_user table instead of mine.

  7. Right click this web.xml file and do a "Save Link As". Note: there is not much in this file other than default settings for tomcat. The reason we need it is to let tomcat know whenever we have published new class files. You'll need this file for the enhanced publishing instructions.
  8. Publish your code to your new "LA" tomcat folder. We set up a second tomcat folder for each student so that your work in a lab activity does not ruin your published web site. The name of your second tomcat folder on cis-linux2 is:


    From now on (because your project will have Java/JSP server side code), you must use ENHANCED Publishing Instructions - as mentioned before, publish to your new tomcat folder (that ends in "_LA") so that you do not wreck your published web site.

  9. Test your published Web API by entering this URL into your browser (substitute your NetAccess username for tua12345): 

    Worth 3 more points (9/9 so far): for publishing the Web API and making sure it worked.

  10. Time Permitting (extra credit), make more progress towards your homework. Work on webAPIs/listOtherAPI.jsp which you will only run locally and not publish.

    Worth 1 extra credit point (10/9 total): Locally running run your webAPIs/listOtherAPI.jsp showing the id and descriptor field of each "other" record in JSON format.

  11. Finishing Up