![]() |
![]() Spring and Fall Semesters 2003 |
Sun-Tue Dec 21-23
Let's go back to this.
Let's work some more on the second part.
Sat Dec 20
Stop making fun of Apache! | ![]() |
Fri Dec 19
Date: Fri, 19 Dec 2003 13:15:16 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348 Fall 2003 Distr. List <dgerman@indiana.edu> Subject: A348 Final Exam The final exam is today at 5pm in Lindley 102 (the lecture room). If you have taken the exam on Mon and you're happy with the grade you received (if you received any) then you don't need to come today. If you haven't taken the exam yet please come tonight. The exam is open book and open notes and based on the review I posted earlier in the week. See you tonight. ... Adrian
Thu Dec 18
<% String me = request.getContextPath() + request.getServletPath(); // who am I? String count = (String) session.getAttribute("count"); // retrieve state Integer stamp = (Integer) session.getAttribute("stamp"); // this part is new (retrieve state) int index = (count == null) ? 0 : Integer.parseInt(count); // initialize state if (stamp == null) { stamp = new Integer(0); } String whichWay = request.getParameter("fun"); // read input to change state (part I) if (whichWay == null) { // protecting against bad input } else { // the empty string is different from null! String userStamp = request.getParameter("stamp"); // read user's stamp (part of input) boolean match; try { match = (stamp.intValue() == Integer.parseInt(userStamp)); } catch (Exception e) { match = false; } // comparing the stamps if (match) { String arg = request.getParameter("arg"); // reading input to change state (part II) if (whichWay.equals("up")) { // changing the state one way or another index += Integer.parseInt(arg); } else if (whichWay.equals("down")) { index -= Integer.parseInt(arg); } else { // something went wrong (we don't do anything) } stamp = new Integer(stamp.intValue() + 1); session.setAttribute("count", index + ""); // save state session.setAttribute("stamp", stamp); // save the stamp (it's part of the state) } else { } } %> <html> <head><title>My Last JSP</title></head> <body bgcolor=white><table> <form method="GET" action="<%=me%>"> The result is currently: <%=index%> <p> <input type="text" name="arg" size=4> <p> Please choose an action: <select name="fun"> <option value="nothing"> Click Me! <option value="up"> Addition <option value="down"> Substraction </select> <p> Then press <input type="submit" value="Proceed"> <input type="hidden" name="stamp" value="<%=stamp%>"> </form> </body> </html>
Wed Dec 17
Can you see how state is being kept in this example?import java.util.*; import java.io.*; class Worm implements Serializable { int calls; Vector v = new Vector(); public static void main(String[] args) { Worm w; try { FileInputStream fis = new FileInputStream("Worm"); ObjectInputStream ois = new ObjectInputStream(fis); w = (Worm)ois.readObject(); ois.close(); } catch (Exception e) { w = new Worm(); } System.out.println( "I have been called " + w.calls + " times." ); w.calls += 1; w.v.addElement(new Date()); for (int i = 0; i < w.v.size(); i++) System.out.println( "***(" + w.v.elementAt(i).toString() + ")***" ); try { FileOutputStream fos = new FileOutputStream("Worm"); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(w); oos.close(); } catch (Exception e) { System.out.println("Something went wrong when writing."); } } }
Here's a session with it:
frilled.cs.indiana.edu%ls -ld * -rw------- 1 dgerman faculty 959 Dec 16 17:48 Worm.java frilled.cs.indiana.edu%javac Worm.java frilled.cs.indiana.edu%ls -ld * -rw------- 1 dgerman faculty 1587 Dec 16 17:49 Worm.class -rw------- 1 dgerman faculty 959 Dec 16 17:48 Worm.java frilled.cs.indiana.edu%java Worm I have been called 0 times. ***(Tue Dec 16 17:49:19 EST 2003)*** frilled.cs.indiana.edu%ls -ld * -rw------- 1 dgerman faculty 266 Dec 16 17:49 Worm -rw------- 1 dgerman faculty 1587 Dec 16 17:49 Worm.class -rw------- 1 dgerman faculty 959 Dec 16 17:48 Worm.java frilled.cs.indiana.edu%java Worm I have been called 1 times. ***(Tue Dec 16 17:49:19 EST 2003)*** ***(Tue Dec 16 17:49:25 EST 2003)*** frilled.cs.indiana.edu%java Worm I have been called 2 times. ***(Tue Dec 16 17:49:19 EST 2003)*** ***(Tue Dec 16 17:49:25 EST 2003)*** ***(Tue Dec 16 17:49:29 EST 2003)*** frilled.cs.indiana.edu%java Worm I have been called 3 times. ***(Tue Dec 16 17:49:19 EST 2003)*** ***(Tue Dec 16 17:49:25 EST 2003)*** ***(Tue Dec 16 17:49:29 EST 2003)*** ***(Tue Dec 16 17:49:33 EST 2003)*** frilled.cs.indiana.edu%ls -ld * -rw------- 1 dgerman faculty 314 Dec 16 17:49 Worm -rw------- 1 dgerman faculty 1587 Dec 16 17:49 Worm.class -rw------- 1 dgerman faculty 959 Dec 16 17:48 Worm.java frilled.cs.indiana.edu%
Tue Dec 16
http://burrowww.cs.indiana.edu:11400/cgi-bin/fall2003finalappts/schedule
That is the link for appointments this week.
Mon Dec 15
Useful link, should you need it.Date: Mon, 15 Dec 2003 12:38:00 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348/A548 Fall 2003 Distr. List <dgerman@indiana.edu> Subject: A348 Final Exam Reminder Dear A348/A548 Friends, Reminder that there's an optional final exam tonight (Mon Dec 15) in Lindley Hall 102 from 7:15pm to 9:15pm. The other exam is on Friday (at a different time so I'll send a reminder about it as we get closer to that date). The appointments script is still available at: http://burrowww.cs.indiana.edu:11400/cgi-bin/fall2003finalappts/schedule The exam is open book, open notes, bring whatever you want to bring (except a laptop). See you tonight. ... Adrian
As it turns out this and this (same) are the current links.
Apparently there's even information on server-side Javascript objects.
Sat-Sun Dec 13-14
Notice this is a modified JSP from Lab Eleven.<html><head><title>JSP Stage One</title></head> <body bgcolor="white"> First we run the scriptlet. <p> <% Integer count = (Integer)session.getAttribute("count"); if (count == null) { session.setAttribute("count", new Integer(1)); int[] a = new int[10]; for (int i = 0; i < a.length; i++) a[i] = a.length - i; session.setAttribute("array", a); } else { int[] a = (int[]) session.getAttribute("array"); int aux = count.intValue(); aux = (aux + 1) % a.length; session.setAttribute("count", new Integer(aux)); for (int i = 0; i < a.length && i <= aux; i++) out.println(i + ": " + a[i] + "<br>"); } %> <p> Which you can't see. <p> Then we print <%= count %> </body> </html>
It initially alocates and stores an array in a session.
It then shows you more and more of the array, with each access.
The HTML in the output doesn't make much sense.
I only kept it so you know what JSP I modified.
Notice the special kind of casting.
Fri Dec 12
The JSP:import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class Hangman extends HttpServlet { String[] words; String secretWord; public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (words == null) { words = new String[26000]; } response.setContentType("text/html"); PrintWriter out = response.getWriter(); try { FileInputStream stream = new FileInputStream("/usr/share/lib/dict/words"); InputStreamReader reader = new InputStreamReader(stream); BufferedReader b = new BufferedReader(reader); String line = b.readLine(); int i = 0; while (line != null) { words[i] = line; i++; // out.println("(" + line + ")<br>"); line = b.readLine(); } stream.close(); } catch (Exception e) { out.println("Something went wrong: " + e.toString()); } secretWord = request.getParameter("secretWord"); if (secretWord == null || request.getParameter("reset") != null) { secretWord = words[(int)(Math.random() * words.length)]; } String me = request.getContextPath() + request.getServletPath(); out.println( "<html><head><title>Hangman</title></head><body bgcolor=\"white\">" + "<form action=" + me + ">" + " Guess the word (" + secretWord + "): " + "<input type=\"text\" name=\"guessedWord\"> <p> " + " <input type=\"hidden\" name=\"secretWord\" value=\"" + secretWord + "\">" + "<p><input type=\"submit\" name=\"reset\" value=\"reset\">" + "</form></body></html>" ); } }
Notice that the part that's missing should be in the prototype.<%! String[] words; String secretWord; %> <% if (words == null) { words = new String[26000]; } // PrintWriter out = response.getWriter(); try { java.io.FileInputStream stream = new java.io.FileInputStream("/usr/share/lib/dict/words"); java.io.InputStreamReader reader = new java.io.InputStreamReader(stream); java.io.BufferedReader b = new java.io.BufferedReader(reader); String line = b.readLine(); int i = 0; while (line != null) { words[i] = line; i++; // out.println("(" + line + ")<br>"); line = b.readLine(); } stream.close(); } catch (Exception e) { out.println("Something went wrong: " + e.toString()); } secretWord = request.getParameter("secretWord"); if (secretWord == null || request.getParameter("reset") != null) { secretWord = words[(int)(Math.random() * words.length)]; } String me = request.getContextPath() + request.getServletPath(); %> <html><head><title>Hangman</title></head><body bgcolor="white"> <form action="<%=me%>"> Guess the word (<%=secretWord%>): <input type="text" name="guessedWord"> <p> <input type="hidden" name="secretWord" value="<%=secretWord%>"> <p><input type="submit" name="reset" value="reset"> </form></body></html>
And that has nothing to do with a distributed application per se.
Thu Dec 11
Steps for the installation of the bulletin board:
cp -r /l/www/classes/a348/software/javaxslt/newsgroups
$CATALINA_HOME/webapps/bulletinBoard
(that's step one)
bulletinBoard
context in server.xml
(step two)
partOne.jar
and partTwo.jar
/l/www/classes/a348/software
$CATALINA_HOME/common/lib
(that's step three, the last one)
Wed Dec 10
Both exams next week in LH102.
Here's the code for the RMI paper.
Here's the Aquaserver source code.
(Compare or relate it to this, this, and this).
Here's the Aquaserver web site.
Here's the Flash code for the web chat.
Sat-Tue Dec 6-9
Date: Tue, 9 Dec 2003 08:31:56 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348/A548 Fall 2003 Distr. List <dgerman@indiana.edu> Subject: A348 Final Update (fwd) Dear A348/A548 Friends, The review for the final has been finished and posted: http://www.cs.indiana.edu/classes/a348/software/rmipaper/fsm.pdf There is a final on Mon Dec 15 at 7:15-9:15pm and another one on Fri Dec 19 at 5-7pm. They have the same format, and you can take them both. The better score will be kept. Homework assignments Six and Seven ask you to implement the four midterm problems using Java servlets (two problems) and JSP (the other two problems). It's OK if you just keep state on the client side with hidden fields (that's what the review mentioned above does too). You are of course welcome to use sessions if you want. Lab Twelve requirements: a) the bulletin board installed (we did it three times in class) b) the content syndication exercise installed c) the XML-RPC exercise completed (to be shown today) d) understand the HTTP based web chat e) go through the RMI exercise once (if you can) (a) and (b) are the more significant requirements. (c), (d), and (e) are more or less optional (depending on your time). Please let me know if you have any questions or concerns. Next week we will be setting up individual appointments for us to talk about your projects one on one. The scheduling script will be up soon. Today in class we will also wrap up the Flash MX/XML-based web chat. See you later today. ... Adrian
Fri Dec 5
Thu Dec 4
So tonight we look at Flash, chat rooms, RMI, XML-RPC, and sockets./l/www/classes/a348/software/model-aqua
Wed Dec 3
Do you see any bugs?<% String message; int compoint, mypoint; String items[] = { "stone", "scissors", "paper" }; String computer = null; if (session.getAttribute("compoint") == null || request.getParameter("reset") != null) { message = "Hello and Welcome to the game."; session.setAttribute("compoint", new Integer(0)); compoint = 0; session.setAttribute("mypoint", new Integer(0)); mypoint = 0; } else { message = "Game has started."; compoint = ((Integer)(session.getAttribute("compoint"))).intValue(); mypoint = ((Integer)(session.getAttribute("mypoint"))).intValue(); computer = (String) session.getAttribute("computer"); String answer = request.getParameter("answer"); if (request.getParameter("answer") != null) { if(answer.equals("stone") || answer.equals("scissors") || answer.equals("paper")){ message = "Choice in this round: " + "The computer's choice was" + computer + "Your choice was" + answer; if ((request.getParameter("answer")).equals(session.getAttribute("computer"))) { message = "The game is a draw." + "The score is now, Computer: " + compoint + "You: " + mypoint; } else if ( (request.getParameter("answer")).equals("stone") && (session.getAttribute("computer")).equals("paper") || (request.getParameter("answer")).equals("paper") && (session.getAttribute("computer")).equals("scissors") || (request.getParameter("answer")).equals("scissors") && (session.getAttribute("computer")).equals("stone")) { compoint +=1; message = " Too bad! You lost this round." + "The score is now, Computer: " + compoint + "You: " + mypoint; } else { mypoint +=1; message = "Very good! You win this round." + "The score is now, Computer: " + compoint + "You: " + mypoint; } } } session.setAttribute("compoint", new Integer(compoint)); session.setAttribute("mypoint", new Integer(mypoint)); // answer = (String) session.getAttribute("answer"); // message = (String) session.getAttribute("message"); } computer = items[(int) (Math.random() * 3)]; session.setAttribute("computer", computer); message += "The computer has chosen (" + computer + ").<p>" + "Now it's your turn. You can choose paper,scissors, or stone."; %> <html> <head><title> stone-scissors-paper Game</title></head> <body bgcolor=#CCCCCC> <form action="<%=request.getContextPath() + request.getServletPath()%>"> <!--Score is: Computer (<%=compoint%>) - User (<%=mypoint%>) -> <%=message%> <p> <!-- The computer has already chosen: <%=computer%> <p> -> Please type your choice here: <input type="text" name="answer"> <p> Submit your choice <input type="submit" value="Proceed"> <p> To start a new game please press <input type="submit" name="reset" value="Reset"><p> </form> </body> </html>
(I am not saying there are any, but are there any---what do you think?)
Tue Dec 2
Alternate
Final Exam time: Monday Dec 15 at 7:15pm-9pm.
You can also (still) take it on Friday Dec 19 at 5pm-7pm.
These files are needed (and no others) for the Bulletin Board in Lab 12.
frilled.cs.indiana.edu%pwd /nfs/grouchy/home/user2/www/classes/a348-dger/software frilled.cs.indiana.edu%ls -ld part* -rw-r--r-- 1 dgerman faculty 1037500 Dec 2 12:08 partOne.jar -rw-r--r-- 1 dgerman faculty 28165 Dec 2 12:08 partTwo.jar frilled.cs.indiana.edu%
Mon Dec 1
Wed-Sun Nov 26-30
Tue Nov 25
Mon Nov 24
Fri-Sun Nov 21-23
Can you build a similar one describing your Tomcat?
Mail processing with PHP:
Here's another JSP from a while ago:
<% int count, right; String message = "Hello and welcome to the addition quiz!"; if (session.getAttribute("count") == null || request.getParameter("reset") != null) { session.setAttribute("count", new Integer(0)); count = 0; session.setAttribute("right", new Integer(0)); right = 0; } else { count = ((Integer)(session.getAttribute("count"))).intValue(); right = ((Integer)(session.getAttribute("right"))).intValue(); try { if (Integer.parseInt(request.getParameter("answer")) == ((Integer)(session.getAttribute("answerKey"))).intValue()) right += 1; else right += 0; } catch (Exception e) { } count += 1; message = right + " out of " + count; if (count == 10) { message = "Final result: " + message + ". New game started "; count = 0; right = 0; } else message = "Your performance thus far: " + message; session.setAttribute("count", new Integer(count)); session.setAttribute("right", new Integer(right)); } int one = (int) (Math.random() * 100 - 50), two = (int) (Math.random() * 100 - 50); session.setAttribute("answerKey", new Integer(one + two)); %> <html> <body> <form action="<%=request.getContextPath() + request.getServletPath()%>"> <%=message%> <p> Question <%=count+1%>. <%=one%> + <%=two%> = <input type="text" name="answer"> <p> <input type="submit" value="Proceed"> <input type="submit" name="reset" value="Reset"> <p> </form> </body> </html>It is clean and compact, and a pleasure to study (I hope).
(The long lines, you ask? Aye (for one) am really really happy it's so easy to use them on the web.)
If you need to upload binary files with PHP.
Some help with the Lindley portfolio:
import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class One extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); String one, two; String what = req.getParameter("picture"); if (what == null) { what = ""; } if (what.equals("one")) { one = "One"; } else { one = "<a href=\"/examples/servlet/One?picture=one\">One</a>"; } if (what.equals("two")) { two = "Two"; } else { two = "<a href=\"/examples/servlet/One?picture=two\">Two</a>"; } out.println("<html><head><title>Mamma mia!</title></head><body bgcolor=\"white\">" + "<table border><tr><td>" + one + "</td><td>" + two + "</td><td>Three</td><td>Four</td></tr>" + "<tr><td colspan=4 align=center>Picture</td></tr>" + "<tr><td colspan=4 align=center>Caption</td></tr>" + "</table></body></html>"); } }Here now is the starting point for the calculator.
<html><head><title>My calculator</title></head><body> <% Integer a = (Integer)session.getAttribute("acc"); if (a == null) { a = new Integer(0); } String argument = request.getParameter("arg"); if (argument == null) { argument = "0"; } int conv; try { conv = Integer.parseInt(argument); } catch(Exception e) { conv = 0; } a = new Integer(a.intValue() + conv); session.setAttribute("acc", a); %> <form> The accumulator is now: <%= a %> <p> <input type="text" name="arg"> <p> </form> </body></html>
Writing a (web) server in Perl.
Here's an improvement on a Pavel Anaschenko very clever observation from last Summer.
Recall the examples from lecture notes whatever.
Then consider this:
class BasicCalculator { int add(int n, int m) { if (m == 0) return n; else return add(n+1, m-1); } } class BetterCalculator extends BasicCalculator { int add(int n, int m) { if (m < 0) return -super.add(-n, -m); else return super.add(n, m); } } class Experiment { public static void main(String[] args) { BetterCalculator a = new BetterCalculator(); System.out.println(a.add( 2, 3)); System.out.println(a.add(-2, 3)); System.out.println(a.add( 2, -3)); System.out.println(a.add(-2, -3)); BasicCalculator b = new BasicCalculator(); System.out.println(b.add( 2, 3)); System.out.println(b.add(-2, 3)); // System.out.println(b.add( 2, -3)); // won't work (don't even try) // System.out.println(b.add(-2, -3)); // won't work (don't even try)) } } /*********************************(sample run)******* frilled.cs.indiana.edu%javac Experiment.java frilled.cs.indiana.edu%java Experiment 5 1 -1 -5 5 1 frilled.cs.indiana.edu% *****************************************************/
Improvement assumes you can't or don't want to touch the code you already have.
(That is the add
in the class BasicCalculator
).
Thu Nov 20
<% // notice the benefit of having used the conventional names for the // request parameter and session variable (the parameter does not need // to be initialized, the session variable does not need to be declared // and/or initialized, since the JSP system takes care of those steps). String arg = request.getParameter("arg"); // read input String me = request.getContextPath() + request.getServletPath(); // who I am String acc = (String) session.getAttribute("acc"); // state (part one) String message = (String) session.getAttribute("message"); // state (part two) int accVal = (acc == null) ? 0 : Integer.parseInt(acc); // o-ho!! String alpha = accVal + "", beta = "undefined", gamma = "undefined"; // why? if (message == null) { message = "Welcome!"; } else { // let message be important! accVal += Integer.parseInt(arg); // we are processing state woo-hooo!! beta = arg; if (accVal > 100) { message = "User won."; } else { // we should reset here!! int comp = (int)(Math.random() * 10 + 1); accVal += comp; gamma = comp + ""; if (accVal > 100) { message = "Computer wins."; } else { message = "Game is under way."; } } } // this was the processing of state session.setAttribute("acc", accVal + ""); // save state (I) session.setAttribute("message", message); // save state (II) %> <html> <head><title>Homework Five</title></head> <body bgcolor=white><table> <form method="GET" action="<%=me%>"> Accumulator: <%=alpha%> + <%=beta%> + <%=gamma%> = <%=accVal%> <%=message%> <p> Enter a number: <input type="text" name="arg"> <p> Then press <input type="submit" value="Proceed"> </form> </body> </html>
Wed Nov 19
import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class Six extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String arg = request.getParameter("arg"); // read input PrintWriter out = response.getWriter(); // so I can print String me = request.getContextPath() + request.getServletPath(); // who I am HttpSession session = request.getSession(); // get ready to retrieve state String acc = (String) session.getAttribute("acc"); // state String message = (String) session.getAttribute("message"); // state int accVal = (acc == null) ? 0 : Integer.parseInt(acc); if (message == null) { message = "Welcome!"; } else { accVal += Integer.parseInt(arg); // start processing state if (accVal > 100) { message = "User won."; } else { int comp = (int)(Math.random() * 10 + 1); accVal += comp; // keep processing state if (accVal > 100) { message = "Computer wins."; } else { message = "Game is under way."; } // one final change } } // this was the processing of state session.setAttribute("acc", accVal + ""); // save state session.setAttribute("message", message); response.setContentType("text/html"); // get ready to show and ask for input out.println( "<html>" + " <head><title>Homework Five</title></head>" + " <body bgcolor=white>" + " <form method=\"GET\" action=\"" + me + "\"> " + " Accumulator: " + accVal + " (" + message + ") <p> " + " Enter a number: <input type=\"text\" name=\"arg\"> <p>" + " Then press <input type=\"submit\" value=\"Proceed\"> " + " </form>" + " </body>" + "</html>" ); } }
Tue Nov 18
So here it is:
---------- From: Boardman, Theodore D Sent: Monday, November 10, 2003 9:07 AM Subject: Website Assistant Developer position available with IU Alumni Association Website Assistant Developer Description: Assist IU Alumni Association with updating and building new Web services. Convert documents for use on Web, create and edit graphics, build cross-platform/cross-browser compatible Web pages that comply with accessibility guidelines. Experience creating database-driven Web pages with PHP and SQL, as well as design and layout with Adobe and Macromedia products is desired. Ability and willingness to learn new tools is a plus. Application procedure/deadline: E-mail resume and links to samples of work to tboardma@indiana.edu by November 24 Location of work and hours: Virgil T. DeVault Alumni Center, minimum 20 hours Compensation: Paid, based on experience. Ted Boardman, Director of Online Services Indiana University Alumni Association 1000 E. 17th St., Bloomington, IN 47408 tboardma@indiana.edu (812) 855-0401 (800) 824-3044 fax: (812) 855-4228 http://www.alumni.indiana.edu Connecting alumni. Serving IU.
Mon Nov 17
Here's the motivation for the paper:
Date: Tue, 18 Nov 2003 16:28:26 -0500 (EST) From: Adrian GermanTo: jett-list Subject: Follow-up paper. Greetings and a wonderful day to everybody! I wrote and posted a follow-up paper to the JETT session "network games". You can find it here: http://www.cs.indiana.edu/classes/a348-dger/software/rmipaper/rmi.pdf It's also indexed at the top of session 5 http://www.cs.indiana.edu/classes/jett/dgerman/session5/ The purpose of the paper is to investigate and summarize the nature of networked interaction in Java as discussed in the JETT session of Saturday November 1. It is shown that using RMI the network becomes transparent. More important is that the development of a distributed application in Java is equivalent to writing a standalone application so one can (and should) design, debug, and test without any network, then switch to a (distributed, networked) run-time environment at the end, in a most straightforward fashion. Thus using RMI for networking is just as powerful as using try/catch blocks for exception handling. There should be a similar increase in productivity, for example. Please let me know if you have any questions about the paper, or if a more introductory level paper on RMI is needed. Thanks a lot and I hope everybody's doing well. ... Adrian
Fri-Sun Nov 14-16
<html><head><title>First to 100</title> <script language="javascript"> var acc = 0; // state var message = ""; // also part of state function calculate() { arg = document.forms[0].arg.value; // read input var oldAcc = acc; // so it would look like fibonacci in the end (for fun and better reporting) if (arg > 10 || arg < 1) { message = arg + " is not a legal value."; } else { // process the state acc += eval(arg); if (acc >= 100) { message = "Game ends. You win."; } else { var comp = Math.round(1 + Math.random() * 10); if (acc >= 100) { message = "Game ends. Computer wins." } else { acc += comp; message = "Game is under way."; } } } // end of process the state (we don't need to store (or retrieve it, for that matter)) document.getElementById("acc").firstChild.nodeValue = oldAcc + " + " + arg + " + " + comp + " = " + acc + " (" + message + ") "; // print state document.forms[0].arg.value = ""; // get ready for new input } </script> </head><body bgcolor=white> <form> <table cellpadding=6> <tr> <td> The value of the game is currently <span id="acc"> 0 (zero). </span> </td> </tr> <tr> <td> Please enter a number (between 1-10): <input type="text" name="arg" size=4> </td> </tr> <tr> <td> When ready, please press <input type="button" value="Proceed" onClick="calculate()" > </td> </tr> </form> </body> </html>
Thu Nov 13
The code is linked in the middle of the notes (available directly here).
Here also is the announcement for the Spring 2004 Mobile Programming Competition:
=========================================================================== S535 Mobile Technologies Spring 2004 Information Systems Department Kelley School of Business This course will explore the technologies for programming mobile devices such as the Pocket PC and the Tablet PC. The course will primarily revolve around a semester long team project for each platform. Students will be expected to develop using platforms for mobile devices such as J2ME and the .NET Tablet PC environment. Graduate student standing and a good programming background are the only pre-requisites. The final deliverable will be evaluated by a panel of experts composed of representatives from the industry and Information Systems faculty. Prizes will also be awarded to the teams delivering the best final project for each platform. Two sections are being offered in the Spring S535-5404: Prof. Vijay Khatri S535-5405: Prof. Raja Sooriamurthi both will meet Fridays 9:00 -- 12:00 If interested in further details please contact raja@indiana.edu
Wed Nov 12
contains three Flash MX games, all of which use XML in some (non-network related) way./l/www/classes/a348/software/makar
Tue Nov 11
103,BL,1403,15004,BAYLISS, CHRISTOPHER DAV,CBAYLISS qianwang 1 103,BL,1403,15005,BIGLER, MICAH GREGORY ,MBIGLER sshayan 1 103,BL,1403,15006,BROWN, ROBERT EDWARD ,ROEBROWN sshayan 2 103,BL,1403,15007,CLENDENING, WENDY RENEE ,WCLENDEN qianwang 2 103,BL,1403,15008,DE LEURY SCHALK, DAVID R,DDELEURY qianwang 3 103,BL,1403,15009,GREENFIELD, MITCHELL SCO,MSGREENF sshayan 3 103,BL,1403,15010,HERMSDORFER, MARK JAMES ,MHERMSDO ferdinc 1 103,BL,1403,15011,HORNING, DAVID RYAN ,DHORNING ferdinc 2 103,BL,1403,15012,KLOPFER, BENJAMIN MICHAE,BKLOPFER sshayan 4 103,BL,1403,15013,LAKE, BRIAN EDWARD ,BLAKE qianwang 4 103,BL,1403,15014,LEE, MIN-HSIANG ,MINHLEE ferdinc 3 103,BL,1403,15015,NAGAYA, CHIAKI ,CNAGAYA sshayan 5 103,BL,1403,15016,NGUYEN, LINH TUYET ,LTNGUYEN ---(dropped)--- 103,BL,1403,15017,OFFICER, AARON M ,AOFFICER sshayan 6 103,BL,1403,15018,PHILLIPS, PATRICK ALLEN ,PAAPHILL ferdinc 4 103,BL,1403,15019,REEVES, SALOME ,SAREEVES ---(dropped)--- 103,BL,1403,15020,REINERT, DRAKE P ,DREINERT qianwang 5 103,BL,1403,15021,ROYALTY, ANDREW W ,AROYALTY sshayan 7 103,BL,1403,15022,THOMPSON, JEFFREY E ,JEETHOMP sshayan 8 103,BL,1403,15023,WELDON, GEORGE MATTHEW C,GWELDON sshayan 9 103,BL,1403,15024,WILKINSON, ROGER LEWIS ,ROLWILKI sshayan 10 103,BL,1403,15025,YEUNG, KING HUNG ,KHYEUNG ---(dropped)--- 103,BL,1415,15026,ANNAIAH, KIRAN HOSAHALLI,KANNAIAH ---(dropped)--- 103,BL,1415,15027,AUGIER, MANUEL ,MAUGIER ferdinc 5 103,BL,1415,15028,BARTELT, VALERIE LISA ,VBARTELT ---(dropped)--- 103,BL,1415,15029,BRAUN, JARRED M ,JAMBRAUN qianwang 6 103,BL,1415,15030,BUULOLO, MAKARIUS ,MBUULOLO ferdinc 6 103,BL,1415,15031,CHANG, YOUNG JOON ,YJCHANG qianwang 7 103,BL,1415,15032,COSTELLO, JAMES CHRISTOP,JCCOSTEL sshayan 11 103,BL,1415,15033,DOSHI, RAHUL RAJNIKANT ,RDOSHI ferdinc 7 103,BL,1415,15034,EMIGH, WILLIAM GARETH ,WEMIGH qianwang 8 103,BL,1415,15035,FLYNN, CHRISTIE SUE ,CHFLYNN qianwang 9 103,BL,1415,15036,GAN, TING ,TIGAN ferdinc 8 103,BL,1415,15037,GAO, RONGKE ,RGAO qianwang 10 103,BL,1415,15038,LA VAN, ERICA HELEN ,ELAVAN sshayan 12 103,BL,1415,15039,MORISSET, IMAN SHABAZZ ,IMORISSE qianwang 11 103,BL,1415,15040,SIBO, WALID ,WSIBO ---(auditing)--- 103,BL,1415,15041,WANG, GENG ,GEWANG ferdinc 9 103,BL,1415,15042,WHITE, PAUL E ,PEWHITE ferdinc 10 103,BL,1415,15043,YAN, YAN ,YAYAN ---(dropped)--- 103,BL,1415,15044,YUDISTIRA, WAHYU ,WYUDISTI ferdinc 11 103,BL,1403,15045,KERY, ROBERT ,RKERY qianwang 12 103,BL,1403,15046,HUH,W ,WHUH ferdinc 12
Fri-Mon Nov 7-10
Date: Wed, 5 Nov 2003 15:25:37 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348/A548 Fall 2003 Distr. List <dgerman@indiana.edu> Subject: A348/A548 Update Dear A348/A548 Friends, Homework Five has just been determined: you are to code your Midterm Exam problems in JavaScript using the tecnhique demonstrated/explained in class, and showcased in Lab Nine. Check the What's Due? (updated) for due dates. If you have any questions and/or concerns please let me know. I will see everybody in labs this week. (Homework Six and Seven will ask you to code the same problems in Java Servlets and Java Server Pages. There won't be a Homework Eight, there is a milestone for the project before the break, and then another one when you turn it in at the end. ... Adrian
Sat-Thu Nov 1-6
Implement your Midterm problems in Javascript (guidelines in Lab
Notes Nine).
Homework Assignment Six and Seven will ask you to
Fri Oct 31
Wed-Thu Oct 29-30
<html><head><title>Conditional output</title></head><body bgcolor="white">
<? if ($arg % 2 == 0) { ?> Even <? } else { ?> Odd <? } ?>
<form>
Type a number: <input type="text" name="arg"> <p>
</form></body></html>
Here's the basic idea behind stamped transactions:
Notice that this now carefully matches the EXACT behaviour of this second one.<? session_start(); if (session_is_registered("alpha")) { } else { session_register("alpha"); $alpha = 0; } if (session_is_registered("stamp")) { } else { session_register("stamp"); } if ($stamp == $stampCopy) { $stamp += 1; if ($fun == "add") { $alpha = $arg + $alpha; } } else { echo "Sorry!<hr>"; } ?> <html> <head><title>Calculator</title></head> <body bgcolor=white> <form> Your balance currently is: <?=$alpha+0?> <p> Argument: <input type="text" name="arg"> <p> Function: <select name="fun"> <option value="non"> click me! <option value="add"> deposit <option value="sub"> withdraw </select> <p> <input type="hidden" name="stampCopy" value="<?=$stamp?>"> When done push <input type="submit" value="Proceed"> </form> </body> </html>
This in spite of using server side sessions to keep state.
It's all about side-effects on the server side during reloading, remember?
Here's also the function we discussed last night.<? if ($fun == "add") { $acc += $arg; } ?> <html> <head><title>Calculator</title></head> <body bgcolor=white> <form> Your balance currently is: <?=$acc+0?> <p> Argument: <input type="text" name="arg"> <p> Function: <select name="fun"> <option value="non"> click me! <option value="add"> deposit <option value="sub"> withdraw </select> <p> <input type="hidden" name="acc" value="<?=$acc+0?>"> When done push <input type="submit" value="Proceed"> </form> </body> </html>
Use it in your shopping carts for the next lab (lab eight).
I will only show you a prototype after the break, to see how it works.<? function get_book_cats($isbn) { $conn = db_connect(); $query = "select dgerman_php_catboo.catid, catname from dgerman_php_categories, dgerman_php_catboo where '$isbn' = dgerman_php_catboo.isbn and dgerman_php_categories.catid = dgerman_php_catboo.catid"; $result = @mysql_query($query); if (! $result) return false; $num_cats = @mysql_num_rows($result); if ($num_cats == 0) return false; $cat_array = array(); for ( $count = 0; $row = @mysql_fetch_array($result); $count++ ) $cat_array[$count] = $row; if (! is_array($cat_array)) { echo "No categories currently available. <br>"; } foreach ($cat_array as $row) { $url = "show_cat.php?catid=".($row["catid"]); $title = $row["catname"]; do_html_url($url, $title); } } ?>
You need to obtain the same effect in your carts, and understand it.
Therefore the question is:
Fri-Tue Oct 24-28
I am grading (not really).
I hope grades for the exam will be available in labs this week.
Thu Oct 23
Here's the message of yesterday:
Date: Wed, 22 Oct 2003 14:44:03 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348 Fall 2003 Distr. List <dgerman@indiana.edu> Subject: A348/A548 Reminder Reminder that your code must be posted by 6pm tonight so I can make up individual questions for the exam tomorrow. You can include if you want four questions that you would like me to ask you tomorrow. This way (maybe) I can focus on what you think you know best and/or would like to see on an exam. I will start making up the exams at 8pm tonight, so there is a 2 hour twilight-zone kind of period in which one could (in principle) still post questions and code. Labs this week are meant to help you with the exam if you need any help. ... Adrian
Tue-Wed Oct 21-22
The errors were:
change
show_state
just developed instead of printState
And here's the program:
There's one more (small) fix we need to bring, can you see it?#!/usr/bin/perl use CGI; use DBI; use MD5; $DB = "DBI:mysql:a348"; $username = "a348"; $password = "a348AG"; $DB_TABLE = "dgerman_midterm"; $SECRET = "something secret"; $EXPIRE = 30 * 60 * 60 * 24; # one month $MAX_TRIES = 10; $ID_LENGTH = 8; $q = new CGI; $arg = $q->param('arg'); $DBH = DBI->connect($DB, $username, $password, { PrintError => 0 }) || die "Couldn't open database: ", $DBI::errstr; my ($session_id) = &get_session_id(); # actually prints a header to recall with id print $q->header, $q->start_html, $q->start_form; my $state = &get_state($session_id); # $state = &change_state($state); #----------------------------- $message = $state->{message}; $acc = $state->{acc}; $turn = $state->{turn}; if ($message && $arg) { # thanks to Christie Flynn for catching this! &process($arg); } $state->{message} = $message; $state->{acc} = $acc; $state->{turn} = $turn; # &printState; #------------------------------ &show_state($state); &save_state($state, $session_id); print qq{ <!-- You entered $arg. --> <p> Enter number: <input type="text" name="arg"> <p> }, $q->end_form; print $q->end_html; sub get_session_id { my ($id) = $q->path_info =~ m:^/([a-h0-9]{$ID_LENGTH}):o; return $id if $id and &check_id($id); my $session_id = &generate_id; die "Couldn't make a new session_id" unless $session_id; print $q->redirect($q->script_name() . "/$session_id"); exit(0); } sub generate_id { my $tries = 0; my $id = &hash($SECRET . rand()); while ($tries++ < $MAX_TRIES) { last if $DBH->do("INSERT INTO $DB_TABLE (session_id, message, acc, turn) VALUES ('$id', 'Welcome', 0, 'user')"); $id = &hash($SECRET . rand()); } return undef if $tries >= $MAX_TRIES; return $id; } sub hash { my $value = shift; return substr(MD5->hexhash($value), 0, $ID_LENGTH); } #--------------------------------(last one needed)----------- sub check_id { my $id = shift; return $id if $DBH->do("SELECT 1 FROM $DB_TABLE WHERE session_id = '$id'") > 0; return $id if $DBH->do("INSERT INTO $DB_TABLE (session_id) VALUES ('$id')"); return ''; } #--------------------------------(retrieve acc)-------------- sub get_state { my $id = shift; my $query = "SELECT * FROM $DB_TABLE WHERE session_id = '$id'"; my $sth = $DBH->prepare($query) || die "Prepare: ", $DBH->errstr; $sth->execute || die "Execute: ", $sth->errstr; my $state = $sth->fetchrow_hashref; $sth->finish; return $state; } sub show_state { my ($state) = @_; print qq{ Message: $state->{message} <p> Acc: $state->{acc} <p> Turn: $state->{turn} <p> }; } sub save_state { my ($state, $id) = @_; my $sth = $DBH->prepare(<<END) || die "Prepare: ", $DBH->errstr; UPDATE $DB_TABLE SET message = ?, acc = ?, turn = ? WHERE session_id = '$id' END $sth->execute(@{$state}{qw(message acc turn)}) || die "Execute: ", $DBH->errstr; $sth->finish; } sub printMessage() { print "$message<p>"; } sub showAccumulator() { print "Current accumulator: $acc <p>"; } sub showTurn() { print "The $turn moves. <p>" ; } sub printState() { &printMessage(); &showAccumulator(); &showTurn(); } sub process { local ($arg) = @_; if ($arg >= 1 && $arg <= 10) { # this comes from the user &change($arg); # see below &showAccumulator(); # print part of state &showTurn(); # print part of state if ($acc == 0) { } # game has ended!... else { $comp = int(rand(10 + 1)); # make this int(rand(10)) + 1 instead (Christie Flynn) print "Computer is adding: " . $comp . "<p>"; # other printing &change($comp); } } else { print "Sorry, " . $arg . " not a valid input value. <p>"; } } sub change { # arg is the input, state is this local ($arg) = @_; $acc += $arg; # check for legal moves elsewhere (in process, for example) if ($acc >= 100) { $message = "The " . $turn . " has won.\nNew game, enter number."; $acc = 0; $turn = "user"; # new game } else { $message = "Game is in progress..."; # if ($turn == "user") { $turn = "computer"; } if ($turn eq "user") { $turn = "computer"; } # notice the eq else { $turn = "user"; } } }
Mon Oct 20
Sat-Sun Oct 18-19
![]() |
Here also is a copy of Pavel Anaschenko's
Summer 2003 PHP version of the Hangman game. (Lecture Notes Fifteen help you get started. Pavel started from that too.)
|
Here's the PHP from last night.
Easy as Pi. Happy.
Last name: Bean. First name: Mr.
Fri Oct 17
Notice how identical it is to the Java program.#!/usr/bin/perl use CGI; $query = new CGI; $arg = $query->param('arg'); # state is composed of $message, $acc, $turn print $query->header, $query->start_html, $query->start_form; $message = $query->param('message'); # retrieve state $acc = $query->param('acc'); $turn = $query->param('turn'); if ($message) { # print "State has been processed. <p>"; &process($arg); } else { $message = "Welcome."; $acc = 0; $turn = "user"; print "State has been initialized. <p> "; } print qq{ <input type="hidden" name="message" value="$message"> <input type="hidden" name="acc" value="$acc"> <input type="hidden" name="turn" value="$turn"> }; &printState; print qq{ <p> Enter number: <input type="text" name="arg"> <p> }, $query->end_form; sub printMessage() { print "$message<p>"; } sub showAccumulator() { print "Current accumulator: $acc <p>"; } sub showTurn() { print "The $turn moves. <p>" ; } sub printState() { &printMessage(); &showAccumulator(); &showTurn(); } sub process { local ($arg) = @_; if ($arg >= 1 && $arg <= 10) { # this comes from the user &change($arg); # see below &showAccumulator(); # print part of state &showTurn(); # print part of state if ($acc == 0) { } # game has ended!... else { $comp = int(rand(10 + 1)); # change to int(rand(10) + 1) (see above) print "Computer is adding: " . $comp . "<p>"; # other printing &change($comp); } } else { print "Sorry, " . $arg . " not a valid input value. <p>"; } } sub change { # arg is the input, state is this local ($arg) = @_; $acc += $arg; # check for legal moves elsewhere (in process, for example) if ($acc >= 100) { $message = "The " . $turn . " has won.\nNew game, enter number."; $acc = 0; $turn = "user"; # new game } else { $message = "Game is in progress..."; if ($turn == "user") { $turn = "computer"; } # in Perl we should do this with eq instead else { $turn = "user"; } } }
Thu Oct 16
For this reason your mock up should use an infinite loop.1. // parse input 2. // retrieve state if (state exists) { // process state (could print in the process) } else { // initialize state } 3. // store state 4. // show state 5. // prepare for new input
Take a look at the example we developed in Java.
(This is finally in its most adequate form.)import java.io.*; // I/O package needed class State { String message; // describes the state of the game int acc; // the actual state of the game String turn; // part of the state used internally State() { this.message = "Welcome to the game, enter a number."; this.acc = 0; this.turn = "user"; // user is always the first to move } void process(int arg) { if (arg >= 1 && arg <= 10) { // this comes from the user this.change(arg); // see below this.showAccumulator(); // print part of state this.showTurn(); // print part of state if (this.acc == 0) { } // game has ended!... else { int comp = (int)(Math.random() * 10 + 1); System.out.println("Computer is adding: " + comp); // other printing this.change(comp); } } else { System.out.println("Sorry, " + arg + " not a valid input value."); } } void change(int arg) { // arg is the input, state is this this.acc += arg; // check for legal moves elsewhere (in process, for example) if (this.acc >= 100) { this.message = "The " + this.turn + " has won.\nNew game, enter number."; this.acc = 0; this.turn = "user"; // new game } else { this.message = "Game is in progress..."; if (turn.equals("user")) { turn = "computer"; } else { turn = "user"; } } } void printMessage() { System.out.println(this.message); } void showAccumulator() { System.out.println("Current accumulator: " + this.acc); } void showTurn() { System.out.println("The " + this.turn + " moves."); } void printState() { this.printMessage(); this.showAccumulator(); this.showTurn(); } } class Program { public static void main(String[] args) { ConsoleReader c = new ConsoleReader(System.in); State a = null; String arg = ""; // input int num_arg; // converted input while (true) { try { num_arg = Integer.parseInt(arg); } catch (Exception e) { num_arg = 0; } // get state: a is it, perhaps you can't retrieve it, // because you're at the beginning so in that case init. if (a == null) { a = new State(); // initialize } else { a.process(num_arg); // process state (could print in the process...) // don't process the newly initialized state (there's nothing to it) } a.printState(); // store state: a is it System.out.print("------------------------------------\n" + "Enter a number: "); // prepare the new input arg = c.readLine(); } } // main } class ConsoleReader { ConsoleReader(InputStream inStream) { // constructor reader = new BufferedReader( new InputStreamReader( inStream)); } String readLine() { // instance method String inputLine = ""; try { inputLine = reader.readLine(); } catch (IOException e) { System.out.println(e); System.exit(1); } return inputLine; } int readInt() { // instance method String inputString = readLine(); int n = Integer.parseInt(inputString); return n; } double readDouble() { // instance method String inputString = readLine(); double x = Double.parseDouble(inputString); return x; } private BufferedReader reader; // instance method }
Today in class we will produce four different programs out of it in 45 minutes.
Wed Oct 15
Tue Oct 14
Here's the Summer 2003 version of the What's New? page.
Fri Jul 25 has the server-side Fibonacci code!
Mon Oct 13
(With answers: in white! Highlight to reveal.)
Thu-Sun Oct 9-12
I used the old edition though.
The script developed in class is here.
Here's the rest of the code developed in class on Thu:
Here's the first transformation:import java.io.*; // I/O package needed class State { String message; int acc; String turn; State() { this.message = "Welcome to the game, enter a number."; this.acc = 0; this.turn = "user"; } void change(int arg) { this.acc += arg; if (this.acc >= 100) { this.message = this.turn + " has won.\nNew game, enter number."; this.acc = 0; this.turn = "user"; } else { this.message = "Go ahead, enter a number."; if (turn.equals("user")) { turn = "computer"; } else { turn = "user"; } } } void message() { System.out.println(this.message); } void accumulator() { System.out.println("Current accumulator: " + this.acc); } void whoseTurn() { System.out.println(this.turn + " moves."); } } class Program { public static void main(String[] args) { ConsoleReader c = new ConsoleReader(System.in); State a = null; while (true) { if (a == null) a = new State(); a.accumulator(); a.whoseTurn(); a.message(); int arg = c.readInt(); if (arg >= 1 && arg <= 10) { a.change(arg); a.accumulator(); a.whoseTurn(); a.message(); if (a.acc == 0) { } else { int comp = (int)(Math.random() * 10 + 1); System.out.println("Computer is adding: " + comp); a.change(comp); } } } } } class ConsoleReader { ConsoleReader(InputStream inStream) { // constructor reader = new BufferedReader( new InputStreamReader( inStream)); } String readLine() { // instance method String inputLine = ""; try { inputLine = reader.readLine(); } catch (IOException e) { System.out.println(e); System.exit(1); } return inputLine; } int readInt() { // instance method String inputString = readLine(); int n = Integer.parseInt(inputString); return n; } double readDouble() { // instance method String inputString = readLine(); double x = Double.parseDouble(inputString); return x; } private BufferedReader reader; // instance method }
Yes, we can improve this, but what matters is something else.<? session_start();
if (session_is_registered("message")) { }
else { $message = "Welcome."; session_register("message"); }
if (session_is_registered("acc")) { }
else { $acc=0; session_register("acc"); }
if (session_is_registered("turn")) { }
else { $turn = "user"; session_register("turn"); }
?>
<html>
<body>
Message: <?=$message?> <p>
Accumulator: <?=$acc?> <p>
Turn: <?=$turn?> <p>
<? if ($arg >= 1 && $arg <= 10) {
$acc += $arg;
if ($acc >= 100) {
$message = $turn + " has won.\nNew game, enter number.";
$acc = 0;
$turn = "user";
} else {
$message = "Go ahead, enter a number.";
if ($turn == "user") {
$turn = "computer";
} else {
$turn = "user";
}
}
?>
Message: <?=$message?> <p>
Accumulator: <?=$acc?> <p>
Turn: <?=$turn?> <p>
<?
if ($acc == 0) {
} else {
$comp = rand(1, 10);
echo "<p>Computer is adding: ";
echo $comp;
$acc += $comp;
echo "<p>Accumulator becomes: ";
echo $acc;
if ($acc >= 100) {
$message = $turn + " has won.\nNew game, enter number.";
$acc = 0;
$turn = "user";
} else {
$message = "Go ahead, enter a number.";
if ($turn == "user") {
$turn = "computer";
} else {
$turn = "user";
}
}
}
}
?>
<form method="POST" action="<?=$SCRIPT_NAME?>">
Enter number here: <input type="text" name="arg"> <p>
Press <input type="submit" value="Proceed"> when done.
</form>
<body>
</html>
That we can think out the whole problem in a "style" then automatically convert it.
Wed Oct 8
Information on creating your<html>
<head><title>First to 100 wins!</title></head>
<body bgcolor="white">
You are sending me this number: <? echo $arg ?> <p>
<? if ($arg >= 1 && $arg <= 10) { ?>
The computer chooses: <? $comp = rand(1, 10);
echo $comp; ?> <p>
<? } else { echo "Nevermind..."; } ?>
The accumulator is: <? $acc = $acc + $comp + $arg; echo $acc; ?>
<hr>
<form method="POST" action="/exam/one.php">
The accumulator currently is: <?= $acc ?> <p>
Enter your number here: <input type="text" name="arg"> <p>
Press <input type="submit" value="Proceed"> to submit.
<input type="hidden" name="acc" value="<?=$acc?>">
</form>
</body>
</html>
nobackup
or scratch
folder (to install PHP).
Tue Oct 7
Date: Mon, 6 Oct 2003 15:59:07 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348/A548 Fall 2003 Distr. List <dgerman@indiana.edu> Subject: A348/A548 Update Dear A348/A548 Friends, The Midterm Exam is on Oct 23, in class. Here's why I am writing about it as early as the beginning of this week. The general collection of topics that we are currently studying in A348 can be briefly summarized as follows: a) CGI programs that keep state on the client side---that use hidden fields to keep state and CGI.pm for basic CGI processing (read/parse) b) CGI programs that keep state on the server side---using a RDBMS such as MySQL, and also DBI.pm for the MySQL connection and CGI.pm for the basic CGI processing. Such programs also need to generate session IDs in the exact same way that program(s) in Lab Six are doing. c) PHP programs that keep state on the client side (w/ hidden fields) d) PHP programs that keep state on the server side (w/ sessions) Please choose four different problems and implement each in a different way by Wednesday October 23. There are many (solved) examples already on the website. Lab Seven solves a problem in three different ways. The four of us will help you with any questions you have, but on Thursday Oct. 23, in class, you will have to take four questions on your four programs, one question per program, as your midterm exam. The exam is closed-book, as you will basically know the questions beforehand. We'll try to explain this in more detail in class on Tue this week. Let us know if you have any questions and/or concerns. Graduate students will have to propose a problem as well (it has to be approved by us too) and post it on their web site by Monday October 13 (a week from today). Please take a look at the posted notes for labs and lectures through the week of the exam. http://www.cs.indiana.edu/classes/a348/spr2003/notes/midterm.html Milestone feedback to be posted later today. ... Adrian
Mon Oct 6
Sun Oct 5
There are also some queries developed but they're not necessarily the answers.
Date: Sat, 4 Oct 2003 10:23:51 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348/A548 Fall 2003 Distr. List <dgerman@indiana.edu> Subject: Milestones 2 and 3 Dear A348/A548 Friends, Appointments are over. I was impressed by the depth and breadth of your interests and by the sheer seriousness (devotion) to the projects that you have chosen. So here's what I would like you to post for Milestones 2 and 3. a) For Milestone 2 please write a brief summary of our appointment. Write freely and mention what we did, what we discussed, what we decided we should do, and what your thoughts are with respect to all of this. I am going to post my own recollections on Monday, to the class web site. b) For Milestone 3 please carry out the tasks outlined above in Milestone 2 and write a short report summarizing your results and conclusions. Make a statement about your project describing your renewed perspective on it after these experiments. Try to have the second milestone posted by Fri 10/10 and the third one completed by next Thu 10/16. I posted an Access database with the data for Homework Three and I think Homework Four should be quite accessible after the lecture on Thu. If you need help or have any questions please let me know. Have a great weekend and we will see you next week. ... Adrian P.S.. If you did not come to an appointment this week and did not talk to me about it I will contact you individually, by e-mail and I will also include this info in the summary I will post on Monday.
Fri-Sat Oct 3-4
/l/www/classes/a348/software
~/.cshrc
to use /usr/local/gnu/bun/make
/nobackup
or /scratch
(instead of /tmp
)
Thu Oct 2
Wed Oct 1
Date: Wed, 1 Oct 2003 08:37:45 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348/A548 Fall 2003 Distr. List <dgerman@indiana.edu> Subject: A348/A548 Reminder Please don't forget that the minute paper for tomorrow will be a summary of Lecture Notes 10 and 11. The minute paper for Tue next week will be a summary of the PHP installation steps, both to be brought to class from home, and up to two pages in length. I will start e-mailing back feedback on the appointments today. Homework Three will also be finalized and posted tonight. Let me know if you need any help or have any questions. ... Adrian
Tue Sep 30
Mon Sep 29
Here's the message sent to the distribution list today:
Date: Mon, 29 Sep 2003 13:02:28 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348/A548 Fall2003 Distr. List <dgerman@indiana.edu> Subject: Individual Appointments Dear A348/A548 Friends, Under What's New entry for Mon Sep 29 (currently on top) there's a link to a program that allows you to make appointments for this week. Please choose a time slot and register for such a short meeting with me. I have all the feedback I need to give you but I want to discuss this project milestone with you in person. I'll give you extremely clear instructions to set up a mock-up for your project or a simple experiment. This should give you a bit more insight into your choice of a project. Then (after our meeting) you'll have until Oct 9 (or so) to do the small experiment and summarize your findings and/or subsequent thoughts about your project. Please register for one of the available times this week. I am going to send individual messages to remind you, especially if I have not seen you in lab this past week or the week before. It's easy to fall behind. But it's possible to catch up in time, and I want to show you how to do that. Hope to see you this week. Here's the direct link to the script: http://burrowww.cs.indiana.edu:11400/cgi-bin/fall2003milestone2-3/schedule Come to think of it this script is also a possible project. Otherwise note that the web site has changed (and will change one more time tonight) and that there is now a Homework Three that should give you the opportunity to design a database and write some SQL to extract info. from it. Homework Four will be about PHP, when we start it, soon. ... Adrian
Sun Sep 28
Complete milestones 2-3 guidelines to be posted Monday.
Meanwhile notice the slight change of schedule with new Homework Three (below).
Fri-Sat Sep 26-27
(This should help everybody get a good grasp of SQL).
Thu Sep 25
Date: Thu, 25 Sep 2003 13:30:05 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348/A548 Fall 2003 Distr. List <dgerman@indiana.edu> Subject: A348/A548 Milestones Milestones 2 and 3 are about to merge and in the following way: we now know what to ask you do for your Milestone 2, so we will try to communicate that to you over the next few (2-3) days. Then you will have two more weeks to do two things: a) report that you did what we asked you to do for Milestone 2, and b) tell us what you think of your project after these experiments For Milestone 2 we will give you specific tasks, very practical, so you get a feel for how the programming for what you chose to work on might be like. And you can make a lot of progress this way. I will have more info (as I said) over the next two days. ... Adrian P.S. I publicly thank Qian, Fulya and Shakila for being the outstanding AIs that they are (so far, as always). Please let us know if or when you need help.
Wed Sep 24
(Choose A348-1403
as the course).
Tue Sep 23
dgerman:e5WZe30aYm0Z.
Fri-Mon Sep 19-22
Previous protected
password was kling0n
must change soon.
We'll contact you soon on the second milestones.
Thu Sep 18
Homework Two now due Tuesday Sep 23.
Current grades to be posted soon.
Labs this week focus on: crontab
,
protected
and a simple quiz.
Here's the code you need to start from for the quiz:
The quiz asks you to start from this and make it into a web script.#!/usr/bin/perl $x = localtime; print $x;
Here's a link provided by Jarred.
(Note though we use Flash MX. I will explain the difference in class).
Here's a note to myself I need to provide more links.
Tue-Wed Sep 16-17
Lecture Notes Five are also useful: they help with Homework Two Part One.
Sat-Mon Sep 13-15
Date: Mon, 15 Sep 2003 14:06:29 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348/A548 Fall2003 Distr. List <dgerman@indiana.edu> Subject: Project Proposals Dear A348/A548 Friends, Since the project is a group enterprise I am hereby giving you some feedback in a fairly public manner. Grades will be posted individually but I would like to encourage everybody to check the project proposals that are being posted across the web space of this class. So, let's start in alphabetical order: 103,BL,1403,15004,BAYLISS, CHRISTOPHER DAV,CBAYLISS Nice page. Milestone one reveals a conservative position. OK. 103,BL,1403,15005,BIGLER, MICAH GREGORY ,MBIGLER Interesting proposal. 103,BL,1403,15006,BROWN, ROBERT EDWARD ,ROEBROWN No Milestone One posted. At least not in sight. 103,BL,1403,15007,CLENDENING, WENDY RENEE ,WCLENDEN Project idea: very good. Minor details to be clarified. 103,BL,1403,15008,DE LEURY SCHALK, DAVID R,DDELEURY Can't find Milestone One. Please post. 103,BL,1403,15009,GREENFIELD, MITCHELL SCO,MSGREENF Very basic, very good and challenging proposal. 103,BL,1403,15010,HERMSDORFER, MARK JAMES ,MHERMSDO Proposal a bit conservative. No problem. Teammate listed. 103,BL,1403,15011,HORNING, DAVID RYAN ,DHORNING Great idea: explore! Perhaps look into VoiceXML as well? 103,BL,1403,15012,KLOPFER, BENJAMIN MICHAE,BKLOPFER Movie database. With XML. Sounds good. 103,BL,1403,15013,LAKE, BRIAN EDWARD ,BLAKE Good idea. Start describing clearly the rules of the game. 103,BL,1403,15014,LEE, MIN-HSIANG ,MINHLEE Interesting. But: I can't see your page properly in Netscape. 103,BL,1403,15015,NAGAYA, CHIAKI ,CNAGAYA Chat application. OK. 103,BL,1403,15016,NGUYEN, LINH TUYET ,LTNGUYEN Can't find Milestone One on the website. Please post. 103,BL,1403,15017,OFFICER, AARON M ,AOFFICER Proposal OK. Describe the rules of the game for the neophyte. 103,BL,1403,15018,PHILLIPS, PATRICK ALLEN ,PAAPHILL An excellent and challenging default project! Great choice. 103,BL,1403,15019,REEVES, SALOME ,SAREEVES Proposal is very good. Question: "whixh"---that's Gaelic, right? 103,BL,1403,15020,REINERT, DRAKE P ,DREINERT Same as HERMSDORFER, MARK JAMES. Default (group) project. OK. 103,BL,1403,15021,ROYALTY, ANDREW W ,AROYALTY Proposal is interesting. Need a simple, scaled-down starting point. 103,BL,1403,15022,THOMPSON, JEFFREY E ,JEETHOMP Proposal oriented towards a real life case/situation. Very good idea. 103,BL,1403,15023,WELDON, GEORGE MATTHEW C,GWELDON Project idea is OK. Please sketch a user's manual for it (for now). 103,BL,1403,15024,WILKINSON, ROGER LEWIS ,ROLWILKI Not bad. But project proposal needs a lot more resolution for now. 103,BL,1403,15025,YEUNG, KING HUNG ,KHYEUNG Idea is OK but needs more resolution. 103,BL,1415,15026,ANNAIAH, KIRAN HOSAHALLI,KANNAIAH Web site down. Likely has dropped the class. Why, may I ask? :-) 103,BL,1415,15027,AUGIER, MANUEL ,MAUGIER Can't see project proposal. Looking forward to it. Nice snowy picture. 103,BL,1415,15028,BARTELT, VALERIE LISA ,VBARTELT Web site in default state. No project proposal? 103,BL,1415,15029,BRAUN, JARRED M ,JAMBRAUN Don't forget to glitz up your page. Game proposal is OK. Specifics. 103,BL,1415,15030,BUULOLO, MAKARIUS ,MBUULOLO Project idea is very good. 103,BL,1415,15031,CHANG, YOUNG JOON ,YJCHANG Auction system. Great idea. Works with GAN, TING. 103,BL,1415,15032,COSTELLO, JAMES CHRISTOP,JCCOSTEL Great idea. Perhaps you can upload XML, and process with XSLT. (Thanks for the update on Myron). 103,BL,1415,15033,DOSHI, RAHUL RAJNIKANT ,RDOSHI Good proposal. A bit on the conservative side but that's OK. 103,BL,1415,15034,EMIGH, WILLIAM GARETH ,WEMIGH Shared whiteboard. (Remind me to show it in class on Tue). 103,BL,1415,15035,FLYNN, CHRISTIE SUE ,CHFLYNN There are a few unknowns in your proposal. But you know that. 103,BL,1415,15036,GAN, TING ,TIGAN Online auction. 103,BL,1415,15037,GAO, RONGKE ,RGAO Shopping cart. 103,BL,1415,15038,LA VAN, ERICA HELEN ,ELAVAN An XML project. I suggest IceWorld, a platform game in Flash. 103,BL,1415,15039,MORISSET, IMAN SHABAZZ ,IMORISSE I have such a game available for you to study and extend it. 103,BL,1415,15040,SIBO, WALID ,WSIBO An independently developed auction site. Proposal looks interesting. 103,BL,1415,15041,WANG, GENG ,GEWANG Project proposal is a bit in need of enhanced resolution: not sure what DDR stands for. East Germany used to go by that name during the Cold War. Also paper-rock-scissors is not a multiplayer game, is it? Not if you play against the computer. 103,BL,1415,15042,WHITE, PAUL E ,PEWHITE Data warehouse. Great idea. Pictures and text. 103,BL,1415,15043,YAN, YAN ,YAYAN Web site not responding. 103,BL,1415,15044,YUDISTIRA, WAHYU ,WYUDISTI Shopping cart. A bit conservative. OK, I guess. 103,BL,1403,15045,KERY, ROBERT ,RKERY Proposal OK. Who is the mentioned partner? Platform is Windows or Unix? End of comments to Milestone One. Please let us know if you need help. ... Adrian P.S. Per one student's request here's a list of student projects (links no longer work) from a while back (Fall 2000) http://www.cs.indiana.edu/classes/a348/fall2000/students.html At that time there were no "default" projects as we have today. Once again: if you need us, please let us know.
Fri Sep 12
#!/usr/bin/perl print qq{Content-type: text/html\n\n}; print qq{<html><head><title>My First Script</title></head><body>\n}; $input = $ENV{"QUERY_STRING"}; $me = $ENV{"SCRIPT_NAME"}; print "($input)<hr>"; foreach $k (keys %ENV) { if ($k eq $input) { print $k, " ==> ", $ENV{$k}, "\n<br>"; } else { print qq{<a href="$me?$k">$k</a>\n<br>}; } } print qq{</body></html>\n};
Thu Sep 11
You need to have it posted on your web site by Sunday night for sure.
Wed Sep 10
Schedule of Office Hours (to be posted today) looks like this:
Adrian Mon 9:30-10:30am LH201D 3:30-4:30pm Tue 3:35-4:35pm Wed 2-3pm Thu 3:35-4:35pm Fri 2-3pm Shakila Wed 3:30-5:30pm LH201 Suite Fulya Thu 1:15-2:15pm LH201 Suite Mon 2-3pm Qian Mon 1-3pm LH112
Tue Sep 9
Don't forget to move the file there, first (fromburrowww.cs.indiana.edu% chmod 711 ~ burrowww.cs.indiana.edu% chmod 711 ~/public burrowww.cs.indiana.edu% chmod 644 ~/public/whoa.tar.gz
lab1
). Is your Lab Assignment One accessible?
Find out here.
Mon Sep 8
Date: Mon, 8 Sep 2003 14:22:24 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348/A548 Distr. List <dgerman@indiana.edu> Subject: A348/A548 Update Dear A348/A548 Friends, Congratulations for your interest and dedication during the first week of classes in this semester's A348/A548. Last week we installed Apache under Unix. At this point you should have a basic understanding of how information is stored, requested, and distributed on the web. This coming week we will learn: a few more Unix commands useful in the maintenance of Apache, a bit of Perl, and the concept of CGI. In labs expect to be given a brief pop quiz on the contents of the lab from the week previous (always). You should also try to have your web site up and running by Tuesday at the end of the day. When we go to labs on WedThu we'll try to give you feedback on your web sites. See you in class tomorrow and in labs later this week. Please let us know if you need help or have any questions. ... Adrian
Sat-Sun Sep 6-7
Please let us know if you run into any problems.http://itaccounts.iu.edu/
Thu-Fri Sep 4-5
Find out here.
Wed Sep 3
/l/www/classes/a348/software
Tue Sep 2
Mon Jun 9
Sat May 10
Fri May 9
Our presentation will contain:
Hope to see you there.
Thu May 8
Sat May 3
Fri May 2
They're in QuizSite administered by the department.
You should find them indexed by the instructor name and course number.
Thu May 1
Wed Apr 30
Tue Apr 29
Date: Mon, 28 Apr 2003 22:16:24 -0500 (EST) From: Jocelyn Bauer <jobauer@cs.indiana.edu> To: Adrian German <dgerman@cs.indiana.edu> Subject: Perl LWP Thanks for your help this morning. I have just been messing around with the Perl LWP for a little bit and have gotten it to do what I wanted. I'm able to call my servlet from my cgi script and have the servlet write to a file. I'll have to work on having the servlet write to the database now. Thanks again. - Jocelyn Date: Mon, 28 Apr 2003 22:20:20 -0500 (EST) From: Jocelyn Bauer <jobauer@cs.indiana.edu> To: Adrian German <dgerman@cs.indiana.edu> Subject: Somemore By the way, here is what I did in case others have the same questions: I couldn't get it to work with the plain get method from the LWP::Simple probably because my servlet took post requests. use LWP 5.64; use CGI; my $other = 'http://burrowww.cs.indiana.edu:11836/stupendous/servlet/StockData'; $name = $query->param('uname'); $pass = $query->param('pword'); my $browser = LWP::UserAgent->new; my $response = $browser->post( $other, [ 'uname' => $name, 'pword' => $pass ] );
Thanks a lot for both notes and congratulations!
Mon Apr 28
Date: Sun, 27 Apr 2003 18:33:13 -0500 From: TaWanna <taessex@indiana.edu> To: dgerman@cs.indiana.edu Subject: monday office hours Professor German, I will be unable to hold office hours Monday April 28, 2003 11:30-1:30. I will also be unable to attend the 1:30 meeting. I have an appointment that I have to attend. I will send you the grades for my lab section. TaWanna EssexMy most sincere apologies for not posting this on time.
Sat-Sun Apr 26-27
import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class One extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); String one, two; String what = req.getParameter("picture"); if (what == null) { what = ""; } if (what.equals("one")) { one = "One"; } else { one = "<a href=\"/examples/servlet/One?picture=one\">One</a>"; } if (what.equals("two")) { two = "Two"; } else { two = "<a href=\"/examples/servlet/One?picture=two\">Two</a>"; } out.println("<html><head><title>Mamma mia!</title></head><body bgcolor=\"white\">" + "<table border><tr><td>" + one + "</td><td>" + two + "</td><td>Three</td><td>Four</td></tr>" + "<tr><td colspan=4 align=center>Picture</td></tr>" + "<tr><td colspan=4 align=center>Caption</td></tr>" + "</table></body></html>"); }This was for the portfolio, as a servlet, and you need a JSP version of it, too.
Now help for the calculator, as JSP.
<html><head><title>My calculator</title></head><body> <% Integer a = (Integer)session.getAttribute("acc"); if (a == null) { a = new Integer(0); } String argument = request.getParameter("arg"); if (argument == null) { argument = "0"; } int conv; try { conv = Integer.parseInt(argument); } catch(Exception e) { conv = 0; } a = new Integer(a.intValue() + conv); session.setAttribute("acc", a); %> <form> The accumulator is now: <%= a %> <p> <input type="text" name="arg"> <p> </form> </body></html>This is only the starting point, and you need a servlet version of it as well.
Fri Apr 25
<% int count, right; String message = "Hello and welcome to the addition quiz!"; if (session.getAttribute("count") == null || request.getParameter("reset") != null) { session.setAttribute("count", new Integer(0)); count = 0; session.setAttribute("right", new Integer(0)); right = 0; } else { count = ((Integer)(session.getAttribute("count"))).intValue(); right = ((Integer)(session.getAttribute("right"))).intValue(); try { if (Integer.parseInt(request.getParameter("answer")) == ((Integer)(session.getAttribute("answerKey"))).intValue()) right += 1; else right += 0; } catch (Exception e) { } count += 1; message = right + " out of " + count; if (count == 10) { message = "Final result: " + message + ". New game started "; count = 0; right = 0; } else message = "Your performance thus far: " + message; session.setAttribute("count", new Integer(count)); session.setAttribute("right", new Integer(right)); } int one = (int) (Math.random() * 100 - 50), two = (int) (Math.random() * 100 - 50); session.setAttribute("answerKey", new Integer(one + two)); %> <html> <body> <form action="<%=request.getContextPath() + request.getServletPath()%>"> <%=message%> <p> Question <%=count+1%>. <%=one%> + <%=two%> = <input type="text" name="answer"> <p> <input type="submit" value="Proceed"> <input type="submit" name="reset" value="Reset"> <p> </form> </body> </html>It is clean and compact, and a pleasure to study (I hope).
(The long lines, you ask? I am really happy it's so easy to use them on the web.)
Thu Apr 24
Wed Apr 23
1800's. Inscription on a Far West Tombstone.That's farHere lies John Bunn(*):
he was killed by a gun.
______________________________
(*)His name was not Bunn, but Wood.
But Wood wouldn't rhyme with gun.
But Bunn would.
owt
(to remind us of the servlet context's name).
Tue Apr 22
If the server is not started you won't be able to connect.
Of course, the server could be started on client demand (as a servlet).
For now, though, we'll be operating it manually.
Mon Apr 21
Fri-Sun Apr 18-20
Evaluations ready to go (CSCI-A348-Instructor_Name
)
They will stay open until May 15, but please turn them in before that.
Thu Apr 17
Tue-Wed Apr 15-16
Wed-Mon Apr 9-14
With the next few lectures we wrap up
After this we will develop some multiplayer games.
T540's (Networked Game Design with Java) Final Exam is a collection of 10 individual presentations. Their final exam is your preview into an exciting domain (multiplayer game design) in which your knowledge of the A348/A548 material would give you a head start. In the next few days I hope to demo this, in class.
Tue Apr 8
Fri-Mon Apr 4-7
Please come during these times to make sure I am here.
Thu Apr 3
Wed Apr 2
Lab Nine is due next week on Wednesday.
Tue Apr 1
Sat-Mon Mar 29-31
Fri Mar 28
Here's also an online reference.
Thu Mar 27
Date: Thu, 27 Mar 2003 09:04:49 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348 Spring 2003 Distr. List <dgerman@indiana.edu> Subject: A348/A548: Brief Update Today in class we will only focus on Javascript. The goal is to understand DOM so we can write Homework 4. Then, to understand the Javascript shopping cart, so we can finish the Remove button, which will be Lab Assignment Nine. Let's make Lab Eight due next Wednesday, instead of today and tomorrow. This way we can briefly discuss is (5 min.) today at the beginning of the lecture. Lab Notes Eight have been updated. Lab Notes Nine will be updated later today to reflect these new changes. Also, I have posted grades for all midterms yesterday. We can discuss them in individual appointments next week and grades can go up or down depending on how appointments go when we discuss your programs. Hope you're doing well. I am writing up new notes for the lecture today to help a bit more with Homework Four. ... Adrian
Wed Mar 26
Now we have a starting point for individual appointments.
We will start scheduling them shortly.
Mon-Tue Mar 24-25
create table alpha_copy as select * from alpha;
(Note the new
Categories
entry in the individual book descriptions).
Sun Mar 23
Gan's office hours changed, now: Wed LH112 7-9pm.
Mon-Sat Mar 17-22
Sat Mar 16
Use it in your shopping carts for the next lab.
I will only show you a prototype after the break, to see how it works.<? function get_book_cats($isbn) { $conn = db_connect(); $query = "select dgerman_php_catboo.catid, catname from dgerman_php_categories, dgerman_php_catboo where '$isbn' = dgerman_php_catboo.isbn and dgerman_php_categories.catid = dgerman_php_catboo.catid"; $result = @mysql_query($query); if (! $result) return false; $num_cats = @mysql_num_rows($result); if ($num_cats == 0) return false; $cat_array = array(); for ( $count = 0; $row = @mysql_fetch_array($result); $count++ ) $cat_array[$count] = $row; if (! is_array($cat_array)) { echo "No categories currently available. <br>"; } foreach ($cat_array as $row) { $url = "show_cat.php?catid=".($row["catid"]); $title = $row["catname"]; do_html_url($url, $title); } } ?>
You need to obtain the same effect in your carts, and understand it.
Therefore the question is:
Sat Mar 15
<html><head><title>Conditional output</title></head><body bgcolor="white">
<? if ($arg % 2 == 0) { ?> Even <? } else { ?> Odd <? } ?>
<form>
Type a number: <input type="text" name="arg"> <p>
</form></body></html>
A bit weird looking, don't you think? One gets used to this in no time, though. (Try it.)
Fri Mar 14
Thu Mar 13
That was the first one, here's the second one:<? if ($fun == "add") { $acc += $arg; } ?> <html> <head><title>Calculator</title></head> <body bgcolor=white> <form> Your balance currently is: <?=$acc+0?> <p> Argument: <input type="text" name="arg"> <p> Function: <select name="fun"> <option value="non"> click me! <option value="add"> deposit <option value="sub"> withdraw </select> <p> <input type="hidden" name="acc" value="<?=$acc+0?>"> When done push <input type="submit" value="Proceed"> </form> </body> </html>
Second one nicely matches the functionality of the first one now.<? session_start(); if (session_is_registered("alpha")) { } else { session_register("alpha"); $alpha = 0; } if (session_is_registered("stamp")) { } else { session_register("stamp"); } if ($stamp == $stampCopy) { $stamp += 1; if ($fun == "add") { $alpha = $arg + $alpha; } } else { echo "Sorry!<hr>"; } ?> <html> <head><title>Calculator</title></head> <body bgcolor=white> <form> Your balance currently is: <?=$alpha+0?> <p> Argument: <input type="text" name="arg"> <p> Function: <select name="fun"> <option value="non"> click me! <option value="add"> deposit <option value="sub"> withdraw </select> <p> <input type="hidden" name="stampCopy" value="<?=$stamp?>"> When done push <input type="submit" value="Proceed"> </form> </body> </html>
Wed Mar 12
I plan to briefly survey what's been posted and notify you of any problems.
Then on Thursday morning the Midterm exams should be posted and finished.
This way I can post grades by Friday night.
Tue Mar 11
Lecture notes for the week posted.
Today we
Homework Four will be due after the break.
Mon Mar 10
One should be able to define the problem by now.
One should also be very close to a solution.
Here's the code:
You see why this is a(lmost a) solution?<? session_start(); if (session_is_registered("acc")) { } else { session_register("acc"); } if (session_is_registered("stamp")) { } else { session_register("stamp"); } if ($stamp == $stampCopy) { if ($fun == "add") { $acc += $arg; } $stamp = rand(0, 100000); } else { ?> Sorry!! <p> <? } ?> <html><head><title>Calculator</title></head><body bgcolor="white"> This is the calculator. <p> Currently your accumulator is: <?=$acc+0?> <p> <form> Please type an argument: <input type="text" name="arg"> <p> ... and choose an operator: <select name="fun"> <option value="non"> click me! <option value="add"> Deposit <option value="sub"> Subtract </select> <p> When done please <blockquote>... push <input type="submit" value="Proceed"></blockquote> <input type="hidden" name="stampCopy" value="<?=$stamp?>"> </form> </body></html>
Also thanks to
Mike de Palma
for the following pointers:
save_state
was not showing properly.
Fixed (see below, under
Thu Mar 6
) the code now looks like this:
This was also noticed by Jocelyn Bauer, on Sunday.sub save_state { my ($state, $id) = @_; my $sth = $DBH->prepare(<<END) || die "Prepare: ", $DBH->errstr; UPDATE $DB_TABLE SET one = ?, two = ?, three = ? WHERE session_id = '$id' END $sth->execute(@{$state}{qw(one two three)}) || die "Execute: ", $DBH->errstr; $sth->finish; }
generate_id
:
Compared to Lab Six thesub generate_id { my $tries = 0; my $id = &hash($SECRET . rand()); while ($tries++ < $MAX_TRIES) { last if $DBH->do("INSERT INTO $DB_TABLE (session_id) VALUES ('$id')"); $id = &hash($SECRET . rand()); } return undef if $tries >= $MAX_TRIES; return $id; }
$acc
is not there.
initialize
:
There was no need tosub initialize { my $state = shift; $state = {} unless $state; $state->{one} = 1; $state->{two} = 1; $state->{three} = 2; return $state; }
initialize
in Lab Six.
Sun Mar 9
(New problems submitted by graduate students are being added to the list).
Sat Mar 8
... both courtesy of Brandon McGhan (bmcghan
).
Fri Mar 7
Thu Mar 6
$DB_TABLE = "dgerman_mar4";
$acc
)
my $state = &get_state($session_id); // ... sub get_state { my $id = shift; my $query = "SELECT * FROM $DB_TABLE WHERE session_id = '$id'"; my $sth = $DBH->prepare($query) || die "Prepare: ", $DBH->errstr; $sth->execute || die "Execute: ", $sth->errstr; my $state = $sth->fetchrow_hashref; $sth->finish; return $state; }
if (! $state->{one}) { $state = &initialize($state); }
$state = &calculate($state); // ... sub calculate { my $state = shift; $state->{one} = $state->{two}; $state->{two} = $state->{three}; $state->{three} = $state->{one} + $state->{two}; return $state; }
&save_state($state, $session_id); // ... sub save_state { my ($state, $id) = @_; my $sth = $DBH->prepare(<<END) || die "Prepare: ", $DBH->errstr; UPDATE $DB_TABLE SET one = ?, two = ?, three = ? WHERE session_id = '$id' END $sth->execute(@{$state}{qw(one two three)}) || die "Execute: ", $DBH->errstr; $sth->finish; }
sub status { my ($state) = @_; print qq{ One: $state->{one} <p> Two: $state->{two} <p> Three: $state->{three} <p> }; }
Wed Mar 5
Also a comparison between the PHP and the Perl/CGI/DBI.pm access to databases.
Tue Mar 4
Note that this helps with Wednesday (if you need help).Date: Sun, 02 Mar 2003 17:16:39 -0500 From: TaWanna <taessex@indiana.edu> To: Adrian GermanSubject: office hours Because I will be in Illinois for interviews, I will not hold office hours this Monday March 3. Instead, I will hold office hours on Wednesday, March 5 at the same time (11:30-1:30). TaWanna Essex
Also, this is only for this week.
Mon Mar 3
DBI.pm
database access
I am going to make a demo of the WildTangent web driver as acccessed from JavaScript too.
Sat-Sun Mar 1- 2
Date: Fri, 28 Feb 2003 17:04:17 -0500 From: Rob Henderson <robh> To: dgerman@cs.indiana.edu Subject: burrowww /tmp usage There are quite a number of users in the burrow that appear to be building php and/or apache in /tmp on burrowww. On all the department Suns, /tmp is a memory filesystem so this is chewing up a lot of virtual memory on the system. Whenever a user needs a large temporary space, they should use /scratch or /nobackup and they can see: http://www.cs.indiana.edu/Facilities/FAQ/General/storage.html for information about how to use these. I'm not sure if these students are in your class or not, but perhaps you could spread the word that /tmp is not a place to be putting lots of files? Thanks a bunch!! --Rob
Fri Feb 28
Wed-Thu Feb 26-27
All homework and lab work that was
No late homework or lab work will be carried over the break.
Tue Feb 25
Mon Feb 24
For the Midterm Exam you only need to provide FOUR (not sixteen) solutions.
If you are a graduate student you don't need to solve your problem.
But you can if you want to, and it could be one of the four.
Send your problem
dgerman@indiana.edu
) so I can post it
Sat-Sun Feb 22-23
What you would have to do (more details to follow pretty soon):
As graduate student you have to do one more thing:
So I will try to have the problems listed here soon.
Fri Feb 21
Implement a CGI script that would behave more or less like this:
This being a web script, it should provide the behaviour of your calculator.prompt> java Vendor Welcome. We sell stamps ($3.40) Please enter money: enter> nickel nickel dollar dollar quarter Thanks. Your credit is $2.35 I need $1.05 more. enter> cent cent Thanks. Your credit is $2.37 I need $1.03 more. enter> dollar quarter Thanks. Your credit is $3.62 The stamps are yours. Your change is: $0.22 Thanks for using this program.
Thu Feb 20
Wed Feb 19
That's where you can get/l/www/classes/a348/software
php-4.1.0.tar.gz
that you need to install.
Tue Feb 18
That, in fact, is what I will be doing today.
Here are problems that you could have been asked to implement for Homework Two:
Mon Feb 17
![]()
There are also a couple of chapters in Hall/Brown. I'll let you identify those on your own (for now). | ![]() |
Sat-Sun Feb 15-16
myusof
)
We set up the first of the Java servers (the one that simply reports).<html> <form method="GET" action="http://burrowww.cs.indiana.edu:43025"> <input type="text" name="uname"> <p> <input type="text" name="pword"> <p> <input type="submit" value="Proceed"> <p> </form> </html> </html>
Then we change the way we send information (to POST):burrowww.cs.indiana.edu% pwd /nfs/paca/san/r1a0l1/dgerman/server burrowww.cs.indiana.edu% ls *.java HTTPServer.java burrowww.cs.indiana.edu% javac *.java burrowww.cs.indiana.edu% java HTTPServer 43025 Have opened port 43025 locally. Client has made socket connection. got: GET /?uname=mjordan&pword=nba HTTP/1.1 got: Host: burrowww.cs.indiana.edu:43025 got: User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:0.9.4) Gecko/20011206 Netscape6/6.2.1 got: Accept: text/xml, application/xml, application/xhtml+xml, text/html;q=0.9, image/png, image/jpeg, image/gif;q=0.2, text/plain;q=0.8, text/css, */*;q=0.1 got: Accept-Language: en-us got: Accept-Encoding: gzip, deflate, compress;q=0.9 got: Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66 got: Keep-Alive: 300 got: Connection: keep-alive got: Referer: http://burrowww.cs.indiana.edu:11400/test.html got:
Now the server's reply is different:<html> <form method="POST" action="http://burrowww.cs.indiana.edu:43025"> <input type="text" name="uname"> <p> <input type="text" name="pword"> <p> <input type="submit" value="Proceed"> <p> </form> </html> </html>
burrowww.cs.indiana.edu% java HTTPServer 43025 Have opened port 43025 locally. Client has made socket connection. got: POST / HTTP/1.1 got: Host: burrowww.cs.indiana.edu:43025 got: User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:0.9.4) Gecko/20011206 Netscape6/6.2.1 got: Accept: text/xml, application/xml, application/xhtml+xml, text/html;q=0.9, image/png, image/jpeg, image/gif;q=0.2, text/plain;q=0.8, text/css, */*;q=0.1 got: Accept-Language: en-us got: Accept-Encoding: gzip, deflate, compress;q=0.9 got: Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66 got: Keep-Alive: 300 got: Connection: keep-alive got: Referer: http://burrowww.cs.indiana.edu:11400/test.html got: Content-type: application/x-www-form-urlencoded got: Content-Length: 23 got: got: uname=lbird&pword=dribl burrowww.cs.indiana.edu%
Fri Feb 14
Happy Valentine's Day!
Thu Feb 13
eOne
(provided) in cgi-bin
.
eTwo
that needs to be placed in cgi-bin
telnet
for Part A.
eTwo.html
in your htdocs
eTwo
)
protected
.
eThree.html
(provided).
eThree.html
calls eTwo
, the script).
eThree
a new script.
eThree
is almost identical to readParse
).
protected
is even bigger now).
process
.
eThree.html
modified to send data to it (process
).
process
directly.
protected
, this is your lab assignment.
GenericClient
, SimpleBrowser
, HTTPServer
.
Wed Feb 12
The plan for tomorrow's lecture:
GenericClient
in Java
Mon-Tue Feb 10-11
Sat-Sun Feb 8-9
CGI.pm
though, which means one needs to
check Lecture Notes Nine first. Lecture Notes Eight and Nine are a review
of OOP concepts in Perl (for CGI.pm
and DBI.pm
later) and Java. It contains only what we'll need later.
In class on Tuesday we will cover Lab Four, mostly.
Congratulations to Xiaomin Liu for her
helloSix
program.
Fri Feb 7
A348-1239
) updated.
Two quizzes for your practice in
QuizSite (dgerman-A348
).
Thu Feb 6
Lecture and lab notes for the next two weeks have been posted.
Please take a look at Homework Assignment Three as well.
Wed Feb 5
Tue Feb 4
The form was sending data to the following scriptburrowww.cs.indiana.edu% pwd /nfs/paca/san/r1a0l1/dgerman/apache/apache_1.3.26/htdocs burrowww.cs.indiana.edu% cat one.html <html> <head><title>Nothing</title></head> <body bgcolor=white> <form method=GET" action="/cgi-bin/anotherOne"> Param alpha: <input type="text" name="one"> <br> Param beta: <input type="text" name="two"> <p> <input type="submit" value="Push me!"> </form> </body> </html> burrowww.cs.indiana.edu%
We changed both the script and the form a few times.burrowww.cs.indiana.edu% cd ../cg* burrowww.cs.indiana.edu% pwd /nfs/paca/san/r1a0l1/dgerman/apache/apache_1.3.26/cgi-bin burrowww.cs.indiana.edu% cat anotherOne #!/usr/bin/perl &header; $input = $ENV{QUERY_STRING}; @pairs = split(/&/, $input); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ s/%(..)/[$1]/g; $in{$name} = $value; } foreach $k (keys %in) { print $k, " --> ", $in{$k}, "\n"; } &trailer; sub header { print "Content-type: text/html\n\n<html><pre>"; } sub trailer { print "</pre></html>"; } burrowww.cs.indiana.edu%
Next time we finish ReadParse
and discuss HTTP.
We'll be covering a lot of Java in the process, so get ready for that too.
Mon Feb 3
The grading scale is listed here.
Sat-Sun Feb 1-2
Fri Jan 31
For the time being you can try it#!/usr/bin/perl &header; $user = $ENV{QUERY_STRING}; if ($user) { @pairs = split(/&/, $user); foreach $pair (@pairs) { # print $pair, "<p>"; ($name, $value) = split(/=/, $pair); # print $name, " has a value of ", $value, "<p>"; $in{$name} = $value; } } else { $user = "Welcome!"; } $number = $in{number} + 1; print qq{ <form> The current number is: <font size=+3>$number</font> </h1> <input type="hidden" name="number" value="$number"> <p> Press <input type="submit" value="Proceed"> to see the next number. </form> }; &trailer; #------------------------------------------------- sub header { print qq{Content-type: text/html\n\n<html> <head><title>Program Two</title></head> <body bgcolor="white"> } } sub trailer { print "</body></html>"; }
Thu Jan 30
There's a lot in the book that we won't have time to cover.
There are a few other references which are just as useful.
I will be posting them here soon.
Wed Jan 29
Here's the script developed in class yesterday:
Call it with:burrowww.cs.indiana.edu% pwd /nfs/paca/san/r1a0l1/dgerman/apache/apache_1.3.26/cgi-bin/one burrowww.cs.indiana.edu% cat alpha #!/usr/bin/perl print qq{Content-type: text/html\n\n}; $user = $ENV{"QUERY_STRING"}; $one = "Lindley 01"; $two = "Lindley 07"; $three = "Lindley 08"; $four = "Lindley 09"; $picture = "Picture"; $caption = "Caption"; if ($user eq "one") { $picture = "<img src=\"http://www.cs.indiana.edu/dept/img/lh01.gif\">"; } else { $picture = "<img src=\"http://www.cs.indiana.edu/l/www/classes/a202-dger/sum99/a202.gif\">"; } print qq{ <html> <head> <title>Program One</title> </head> <body bgcolor="white"> <table border cellpadding=2> <tr> <td> $one <td> $two <td> $three <td> $four <tr> <td colspan=4 align=center> $picture <tr> <td colspan=4 align=center> $caption </table> </body> </html> }; burrowww.cs.indiana.edu%
(Remember that if you call it with a different query string it produces a different answer).http://burrowww.cs.indiana.edu:11400/cgi-bin/one/alpha?one
Tue Jan 28
burrowww.cs.indiana.edu% pwd /nfs/paca/san/r1a0l1/dgerman/Jan23 burrowww.cs.indiana.edu% ls -ld * -rwx------ 1 dgerman faculty 390 Jan 23 19:00 one burrowww.cs.indiana.edu% cat one #!/usr/bin/perl $balance = 0; print "Hello!\necho> "; while ($line = <STDIN>) { # print "$line"; if ($line =~ /^bye$/i) { print "Goodbye!\n"; last; } ($fun, $arg) = split(/ /, $line, 2); if ($fun =~ /^add$/i) { $balance += $arg; } elsif ($fun =~ /^sub$/i) { $balance -= $arg; } else { } print "Balance now becomes: $balance\n"; print "echo> "; } burrowww.cs.indiana.edu% ./one Hello! echo> add 1 Balance now becomes: 1 echo> add 4 Balance now becomes: 5 echo> sub 2 Balance now becomes: 3 echo> Balance now becomes: 3 echo> add something else Balance now becomes: 3 echo> bye Goodbye! burrowww.cs.indiana.edu%
Mon Jan 27
Sun Jan 26
From: Matthew Caine Garrett <magarret@cs.indiana.edu> To: Adrian German <dgerman@cs.indiana.edu> One thing I forgot to mention; Because of the difficulty with working with command line interfaces I noticed with a lot of students in both of my lab sections in working with command line, I'm going to suggest, [...] that they take the UNIX Basics workshop. It's Tuesday, January 28 from 5:30-8:30 in IMU M088. [This would give just about anyone] ample opportunity to bone up on command line usage.
Sat Jan 25
If for some reason you don't have Lab One done by Fri night,#!/usr/bin/perl $username = $ARGV[0]; if ($username eq "") { `yes | rm -ir wh* exp* `; print `ls -ld * `; exit; } `cp /u/$username/public/whoa.tar.gz . `; `gunzip whoa.tar.gz`; `tar xvf whoa.tar`; print `du -a exp*`; print `more exp*/doc*/doc?.txt`; print "Should I delete it? "; $answer = <STDIN>; if ($answer eq "yes") { `yes | rm -ir wh* exp* ` ; print ` ls -ld * `; }
They are structured ways to help you catch up. (Or, catsoup).
But first
Thu-Fri Jan 23-24
Don't forget to move the file there, first (fromburrowww.cs.indiana.edu% chmod 711 ~ burrowww.cs.indiana.edu% chmod 711 ~/public burrowww.cs.indiana.edu% chmod 644 ~/public/whoa.tar.gz
lab1
). Is your Lab Assignment One accessible?
Find out here.
Wed Jan 22
The necessary info is somewhere on that page.http://kb.indiana.edu/data/aelc.html
(It's under Secure Communications in IUware).
Tue Jan 21
Schedule of office hours updated.
Sun-Mon Jan 19-20
Sat Jan 18
Thu-Fri Jan 16-17
Wed Jan 15
Also the files location is /l/www/classes/a348/software
Tue Jan 14
This semster's list of port assignments has been posted.
Mon Jan 13
A348/A548