Two Ways of Coding

  1. Using your own computer to code, upload to csa3.bu.edu and run on csa3.bu.edu using its PostgreSQL and Tomcat.
  2. Install your own PostgreSQL and Tomcat and run everything on your own machine.

The Bring-Your-Own-Laptop Way

Attention: Mac users please follow new instructions.

PostgreSQL and Java for Mac Users

I noticed there are a lot of Mac users here. And I just found out that the docker way of doing it doesn’t quite work. What I recommend is doing the followings.

  1. Go http://postgresapp.com/ and install PostgreSQL directly on your own machine.
  2. Start that application, create all necessary tables according to photoshare/docs/photoshare_schema.sql
  3. Update photoshare/META-INF/context.xml with username being your Mac’s login name and password being empty string.

Java 8 works fine on Mac.

  1. So just execute /usr/libexec/java_home and copy the output path as JAVA_HOME
  2. Also update that path in photoshare.properties file

You don’t need any other configuration. Just remember to start Postgres.App application before testing.

For Others

You need your own PostgreSQL, and make sure you have JDK 1.6 installed.

Install JDK 1.6

You can download here. Or if your operating system has a package manager like apt and homebrew, look for openjdk or similar package.

Make sure JAVE_HOME points to the JDK folder after installation. You can google how to set up JAVA_HOME environment variable windows/mac/linux

Install Docker

Follow instructions here https://docs.docker.com/installation/#installation. Look for your platform.

Start PostgreSQL

docker run --name db -e POSTGRES_PASSWORD=pwd -d -p 5432:5432 postgres

This will give you a running PostgreSQL database on localhost:5432 with username postgres and password pwd. You can then use psql to connect to it.

If you have psql on your system, then

psql -h localhost -U postgres

Otherwise, you can use the psql from the same image you used to start the PostgreSQL server.

docker run -it --rm --link db:postgres postgres sh -c 'exec psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres'

There are a lot of cheat sheet for psql, and this is one of them. Just google it.

Check and Modify PA2 Files

Based on your own environment, you need to modify things like JAVA_HOME, PostgreSQL username, password and address, and all related things. Other than these, you can just follow PA2 instructions.

Useful Pages

  • JSP Tutorial: http://www.jsptut.com/
  • JSP Expression Language Reference Card: http://refcardz.dzone.com/refcardz/essential-jsp-expression
  • JSP Cheat Sheet: http://ndpsoftware.com/JSPXMLCheatSheet.html
  • Java Cheat Sheet: http://introcs.cs.princeton.edu/java/11cheatsheet/
  • HttpServlet API Ref: http://docs.oracle.com/javaee/6/api/index.html?javax/servlet/http/HttpServlet.html
  • What is “servlet”: https://www.wikiwand.com/en/Java_servlet
  • What is “ant” in your “ant -f photoshare.xml all”: http://www.wikiwand.com/en/Apache_Ant
  • What is “tomcat” in your “catalina.sh start”: http://www.wikiwand.com/en/Apache_Tomcat
  • JavaScript Cheat Sheet: https://www.addedbytes.com/cheat-sheets/javascript-cheat-sheet/, http://christianheilmann.com/stuff/JavaScript-DOM-Cheatsheet.pdf
  • JavaScript Official Reference Guide: https://developer.mozilla.org/en-US/docs/Web/JavaScript
  • HTML Cheat Sheet: http://www.simplehtmlguide.com/cheatsheet.php
  • CSS Cheat Sheet: http://www.cheatography.com/davechild/cheat-sheets/css2/

Three Slides