Apple: Java, JDBC, and JSP Course
This is a blog page for the folks at Apple in Sacramento. We had a good time talking about Java, and here are some of the things that we've done.
Interesting Links and Info
- Jayson's E-mail: jfalkner@umich.edu
- On-line Java 5 SE JavaDocs
- Sun's Java Docs Search Box
- Java Performance White Paper
- Win32 Language Performance Shootout
- JAVA_OPTS is the system property that you can use to set JVM parameters, e.g. try "JAVA_OPTS=-Xmx512m" to have the JVM use 512 os RAM.
- Some examples of optimization
- Stressing the garbage collector: MemoryMonster.java
- Non-Buffered File IO (~3 seconds to read Enable2k)
- Basic Buffered IO (~50 milliseconds)
- Buffered IO, bulk byte reading (~0 milliseconds)
- ClassLoader Example (for Alberto)
- Netbeans OSX Keyboard Shortcuts
- auto-format code: CMD + SHIFT + f
- auto-import packages: CTRL + SHIFT + f
- renaming class (all uses of it, including uses in other classes): CTRL+Click on the .java file->Refactor->Rename
- renaming package (also auto-updates all package declarations): CTRL+Click on the package->Refactor->Rename
- renaming a variable (auto-updates all uses of that variable): Highlight the variable->CTRL+Click->Refactor->Rename
- auto-generate getters and setters: Highlight the class fields->CTRL+Click->Refactor->Encapsulate Fields
- comment out multiple lines simultaneously: Highlight the lines->CTRL+SHIFT+t
- uncomment multiple lines simultaneously: Highlight the lines->CTRL+SHIFT+d
Anagram Challenge Example
If you rearrange the names of "Al Kaline", "Al Green", "Eric Clapton", "Liam Brady", "Lou Reed", "Tom Cruise", what words from the English dictionary can you make. Each name will make at least one word.
- Enable2k Dictionary
- Dictionary.java
- Main.java (incomplete, you add the methods)
- Solution: AnagramSolver.java
Text Twist Challenge
The Tuesday morning challenge is to modify your Anagram code to find all words that you can make, i.e. all the scrabble words that you could play or all of the words needed to win at Text Twist.
If you send in a screenshot of your high-score I'll put it on this page for others to see. We'll keep the best score posted on-line as the winner.
Current Text Twist High Score: Bill Newcomb
Tuesday Scrabble Challenge
We're getting closer to playing a full game of scrabble. For today's challenge you are asked to write code that attempts to find the highest scoring word from a rack of scrabble letters. You'll be given a full bag of scrabble letters, and your code will be tested to see how highly it can score using those letters.
Wednesday Scrabble Challenge
We're now playing real scrabble. Your class must return an array of PlacedScrabbleLetter objects, which represents both a word and the location on the board that the word is placed. Several helper method have been added to the ScrabbleBoard class, and be sure to take a look at the two example scrabble players: ChooseFirstWordScrabblePlayer and ExtendUsingFirstWordScrabblePlayer.
Note that the board now also has letter and word multipliers same as a normal scrabble board. Finding the longest word is no longer the best bet! Be sure to consider what placed word would score the highest using the ScrabbleBoard class's calculateRealWordValue() method.
Results from Wednesday scrabble are here. Out of 1000 games played John Morgan dominated, winning 84% of the matches. Here is a summary of the results and here is a link to a log of all 1000 games (~1MB download).
Average Scores: Morgan: 195 Andy Masuo: 119 DukeNukem: 43 Win Percentage: Morgan: 845 out of 1000; 84% Andy Masuo: 146 out of 1000; 14% DukeNukem: 9 out of 1000; 0%
Friday Links: JDBC, JSP, and Servlets
Here are a bunch of links for the last day of class. These are all related to JDBC, JSP, and Servlets.
- Howto configure the MySQL JDBC driver on Tomcat 4.x
- Tomcat 5.5 MySQL JDBC DataSource configuration
- MySQL JDBC Driver
- HTML Specification
- Cascading Styles Sheets Specification
- Servlet Specification
- JavaServer Pages Specification
- Example Webapp: TopCall
This example shows uses of JDBC both with the original Class.forName() mechanism of creating a connection and the JDBC 2+ DataSource method (i.e. connection pooling in Tomcat). The example also happens to be generic code that you can use to do any SQL query and display the results as both a HTML table or a tab-delimited file. - Unzip and set the folder as your project's folder in Netbeans.
- The 'src/java' folder contains all the Java sources including the helper code that uploads data to MySQL.
- The 'web' folder contains the webapp with everything, but the compiled source and the JSTL JAR files
- Under the project's properties add the JSTL JAR files
- JSP, Servlet, and Threading Example:
This is an example web application showing both a servlet and JSP. The JSP starts up a background process and presents a progress bar that updates when the page is refreshed. The servlet provides an example of generating binary output. The servlet can dynamically add signatures to an existing image and send the contents to a user as a JPG. - Unzip the archive and set it as the project directory for a Netbeans.org web application.
- Java source-code and web app files are split same as the above project. Load them in to netbeans as 'existing sources'.
- A copy of the WAR is include and it is an easy way to drop the code in to Tomcat and see it work.
- Download page for my book, "Servlets and JavaServer Pages; the J2EE Web Tier"
- Login or register to post comments
- Printer-friendly version
- jfalkner's blog
- 2195 reads





