CS406 Internet Programming with Java

Roger W. Webster, Ph.D.

Course Assignments:

I. html/cgi Assignment #1

First html/cgi Laboratory Exercise - Getting started

  1. http protocol lab exercise: Test out the http protocol using telnet to the http://cs.millersv.edu server and GET /index.html via http commands, also get a gif and jpg.
  2. A cgi/form program that modifies form data via a cookie.

Java Laboratory Exercises

Write the java source code for "Sample Window - HELLO WORLD" and the html Java applet to execute interactive content on the world wide web (see in class notes). Modify the applet to take in parameters via theapplet tag and print the parms in the Java window. Get four parms: one string for the image file you want to display, one string for the sound you want to play, two integers, x and y, which is where you want the image to be displayed in the applet. Your java applet should get the image file in the parameter and display it, and get the sound file in the parameter and play it.

When it all works, upload it to your public_html dir on the SUN systems and then try it via netscape and IE. Pass in java source code, html source code, with the URL printed on it for me to try.

Good Luck.
 


 

Java Laboratory Exercises

Write the java source code for "the 8 Puzzle" program and the html Java applet to execute interactive content on the world wide web (see in class notes). The 8 puzzle consists of a 3x3 square of numbers from 0 to 8. The 0 grid is the empty grid. Build a gui to allow the user to move the empty tile around to solve the 8 puzzle. The solution to the 8 puzzle is always a 3x3 grid with 123 on top row then 804 in middle row then 765 in the last row. Possible beginning puzzles are shown below. You can for extra credit shuffle the tiles from their initial solved state to a random start state.

283
164
705

216
408
753

134
802
765

 


 

Java Lab Exercise # 2 Java Rush Hour Program

 

Write the html file and the Java Applet source code to show executable interactive content on the world wide web (see in class notes). This problem is called the "Deadlock Unsnarling" program. A process in a multi-processing operating system is said to be Deadlocked (in a state of Deadlock) if it is waiting for a particular event that will not occur (see fig. 1). In an Operating System deadlock, one or more processes are deadlocked. Some Operating Systems have the ability to unsnarl circular deadlocks by backtracking through the process list and the resources they hold. This Java Applet will simulate this OS process via the game called "Rush Hour" (see fig. 2).

Figure 1.

This java applet is to be comprised of a 6 x 6 grid with cars (2 blocks) and trucks (3 blocks). The user is to be able to move the cars and trucks around the grid with the contraints (walls, and the cars and trucks can only move forward and backwards). When the Red car can get out of the deadlock, the problem is solved (see image below).

Figure 2.

 Figure 3.

Figure 4. Top View of Various Cars and Trucks.

Part one is to put up the grid and the cars and trucks on the screen.

Part Two is to place 6 panels on the screen on the top row. Load the car and truck images into two of the panels. then write the Java code to switch the car image panel with the empty panel when the user clicks on the car panel, then the empty panel. Perform some error checking.

Part Three is to finish programming the rush hour game so that it works. You can use my sample code (see below) to help you. You will need to add the North-South code and perform some additional error checking. Also, you must get the images, row, column, kind of vehicle, and East-West direction info from the html parms via Java code, i.e., one Java program that can read different puzzles from html parameters. There are 4 trucks (yellow, blue, purple, green). There are 12 cars (red, lite blue, orange, lite green, purple, yellow, pink, brown, dark green medium green, tan).

Here's some preliminary code to get you started: rush.html.

 


Previous Assignments

·  Java Lab Exercise # 2
 

Write the java source code for "Sample Menubar Window" and the html Java applet to execute interactive content on the world wide web (see in class notes). Modify the applet to take in parameters via the applet tag. Get parameters for the image files you want to display, and the menuitems they are associated with. Your java applet should get the image files in the parameter and display them when the user pulls down the appropriate menu.

When it all works, upload it to your public_html dir on the SUN systems and then try it via netscape and IE. Pass in java source code, html source code, with the URL printed on it for me to try.

see http://cs.millersville.edu/~webster/cs406java/menubar/menuexample.html for what it should roughly look like.

Good Luck. 


Java Client-Server Socket Lab Exercise

Modify the java source code for "Sample Client-Server Socket Demo"  and the html Java applet to make it work on the world wide web (see in class notes). Modify the applet.
 

Good Luck.


·  Java Lab Exercise - Sockets and Networking 

Write the java source code and html Java applet to lookup people's email addresses by Lastname and/or First name. Use the finger port (79) to connect to the cs.millersv.edu machine. Modify the code at http://cs.millersv.edu/java/mucs.dir/demos/FingerApplet.html to make the screen nice and neat with fields for Lastname Firstname Email Address. Remember, the finger command can return more than one match on the name fields that are typed in.

If you modify the code I have already done, you need to make it jdk1.2 compliant (no jdk1.0 event handling). You can use -deprecation to see what is deprecated.


·  Java Lab Exercise



Write the java source code for and the html (Java applet) to manipulate background colors, etc. as specified in the lab manual (handout). Do items 1-4 in handout.


·  Java Lab Exercise


 

Write the java source code and html Java applet to create a 2D graph of hierarchical data. Modify the Java code on the cs server that shows the CS curriculum hierarchy. The java applet should draw the nodes in hierarchical fashion based upon the data passed via params in the html file. You will need to copy to your account Graph.java and edit and recompile into a callable applet. The Graph.java program is not to scramble the data. The file is at http://cs.millersv.edu/java/demo/GraphLayout/newmucsgraph.html 


·  Java Lab Exercise

Write the java source code and html Java applet to perform executable interactive content on the world wide web. Modify the Client-Server code to pop-up a window with the two text fields (input and output), and add a button to quit. Add menu items that "tear-off". You will need to copy to your account AppletClient.java and edit and recompile into a callable applet. The file is $JAVAHOME/java/mucs.dir/demos/examples/section7/AppletClient.java. 


·  Java Lab Exercise:

Modify the CS406 Cient-Server java applet so that it just simply puts up the windows (no client-server code). Make sure all windows work properly and quit properly. Make sure the windows are preserved even if the user puts other windows in front java puzzle applet. Use the source code already written in the cs406 web pages of demos as a start. GOOD LUCK!


·  Java Lab Exercise

Modify the Triangle puzzle java applet so that it works. The user must be able to easily jump the pegs. Make sure all windows work properly and quit properly. There should be a choice of: (1) User play the puzzle. (PART I). (2) Computer solves the puzzle. (PART II). This assignment MUST use images to implement the triangle puzzle. Make sure the graphics/images are preserved even if the user puts other windows in front of the triangle java puzzle applet. Use the source code already written in the cs406 web pages of demos as a start.


Sample Java Projects

Java Project 1.
Faculty Scheduler and Meetings Applet
Make a java applet that will :

·  Input a faculty member's course schedule form.

·  Change a faculty member's course schedule form.

·  Show all faculty member's schedules (form).

·  Show a particular faculty member's schedule (form).

·  Show all the available times and days that any N number of faculty members can meet.

·  Notify the parties of the meeting request by email.


Sample Java Project 2.


Spreadsheet Applet
Department Chair's Course/Faculty/Room Scheduler Spreadsheet Applet
Make a java applet that can :

·  Input a department's course schedule in a spreadsheet(see form).

·  Be able to sort the spreadsheet by up to 3 columns (A w/in A -> B, w/in AB -> C).

·  Open and save a working spreadsheet.

·  Use Client_server code to do the open/save.

·  Widen and narrow columns (by user).

·  Upload to fixed file format in ascii for registrar. 


Sample Java Project 3.


Modify the Client-Server Battleship java applet in the cs406 web pages
Alllow 2 people (clients) across the net to play the game (using the cs machine as a server). Also, change the compurer player code to play smarter, i.e., it should 'know' what it is looking for and hit only on the spots in the grid that could be the missing ship.

Other Sample Java Projects see CS406 Client_Server Java Projects.

 

 


Java Lab Exercise #4: Client-Server Computing - Threads, Sockets and Networking.

Write a Java server and a Java applet to do client-server computing over the Internet. The applet is to spawn three threads. Each thread is to read an integer from the Java Server (via a socket), increment it by one, then write it back to the Server. Use the Java synchronize() facility to assure mutex on the socket reading and writing. Make sure it is jdk1.2 compliant (no jdk1.0 event handling). Make the server code test each incrementation. If there is a problem, send 0 to all clients who request/read the socket. Use the zansiv.millersville.edu machine to run the java Server and your web page that has the client applet code... Make a web page to start the server up.

see cs406 Java web site for client-server code and examples.

good luck.

 


Back to Internet Programming with Java and Perl.