Two Ways of Coding
- Using your own computer to code, upload to
csa3.bu.eduand run on
csa3.bu.eduusing its PostgreSQL and Tomcat.
- Install your own PostgreSQL and Tomcat and run everything on your own machine.
The Bring-Your-Own-Laptop Way
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.
- Go http://postgresapp.com/ and install PostgreSQL directly on your own machine.
- Start that application, create all necessary tables according to
photoshare/META-INF/context.xmlwith username being your Mac’s login name and password being empty string.
Java 8 works fine on Mac.
- So just execute
/usr/libexec/java_homeand copy the output path as
- Also update that path in
You don’t need any other configuration. Just remember to start Postgres.App application before testing.
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
homebrew, look for
openjdk or similar package.
JAVE_HOME points to the JDK folder after installation. You can google
how to set up JAVA_HOME environment variable windows/mac/linux
Follow instructions here https://docs.docker.com/installation/#installation. Look for your platform.
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.
- 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
- HTML Cheat Sheet: http://www.simplehtmlguide.com/cheatsheet.php
- CSS Cheat Sheet: http://www.cheatography.com/davechild/cheat-sheets/css2/