CS636 Class 13 Intro to tomcat, JPA

Intro TOMCAT

Servlets are key to handling user input in a web app.

Also dynamic html

URL accessing my tomcat installation: http://topcat.cs.umb.edu:11600/cs636/index.html

local path = /cs636/index.html on this tomcat installation

This file in the filesystem: /home/eoneil/cs636/tomcat-6.0/webapps/cs636/index.html

Root of my tomcat’s website files: /home/eoneil/cs636/tomcat-6.0/webapps

Here GET command is GET /cs636/index.html HTTP/1.1, done after TCP connection to topcat.cs.umb.edu on port 11600.

Tomcat interprets the local path:  web app name "cs636", file index.html within it.

Since it's HTML, tomcat just reads it and sends it back on the same TCP connection.

Coming up:

  1. You install tomcat on topcat, get it working with your assigned TCP ports on topcat. Way to test your project deliveries on topcat
  2. You install tomcat on your development machine, using port 8080.

Classic tool “telnet”: sets up TCP connection for you. Try it out in hw4.

HTTP is stateless

 Intro to JPA

O/R Mapping idea: take advantage of the similarities in data model and object model and automate the conversion of database data to/from objects.

Hibernate project evolved into JPA1, then JPA2 standards, part of JEE, close to EJBs but separable.

Although JPA2 is considered part of JEE, not JSE, it does not depend on anything else in JEE, so can be used as an extension of JSE, as we will do for pa2.

JPA2, released in late ’09, is widely used already and supported by Hibernate 3.5 and Eclipselink, among other “providers”, i.e., implementations.

Mappings specified by annotations in domain classes or XML files—we’ll use annotations, the programmer’s favorite method.

« persistent object » - standard terminology, but possibly misleading

The domain objects are tied to persistent row(s) in DB

Identity

Java object identity: its ref’s value,the address of object in memory

       but this changes from one scratch copy to another

Persistent identity: PK val of row in DB: Typically a field(s) in the object

Worry: We could end up with 2 Java objects with the same persistent id

One thing the JPA runtime does is make sure there’s only one

Changes in a Java object can happen anytime via method calls by program

vs. Change in the persistence(row) via transactions

These changes are not perfectly synchronized, so we end up with Java objects being “quasi-transactional”

We have to tell JPA about a domain object before it can help us with persistence

Look at Chap. 13 slides.