Spring Semester 2002


Thu Aug 8
Instructions for Students to complete CS evals through BEST:

1)  Go to http://www.indiana.edu/~best/
2)  Click on "Students" under "QuizSite"
3)  Click on Instructor and Course drop-down box
4)  Choose link to desired course evaluation
    All choices are preceeded by "csci"

        *LECTURE SECTIONS:
        Lecture sections are preceeded by an upper-case letter
        (ie: csci-A110)

        *LAB SECTIONS:
        Lab sections are preceeded by lower-case letter
        (ie: csci-a110)

5)  Choose "Do a Current Activity"
6)  Highlight name of instructor you wish to evaluate
7)  Click "Proceed" button
8)  Answer the 30 questions and click the "SUBMIT" button.
9)  **PLEASE REMIND STUDENTS TO CLICK THE SUBMIT BUTTON**
10) Repeat process for each additional lecture/lab instructor

Wed Aug 7
<html><body bgcolor="white"><script language="javascript">

    acc = 0; 

    function etupmoc(msg) { 

      coin = document.forms[0].coin.value;

      document.getElementById("msg1").innerHTML = "You have typed: " + coin; 

      if (coin == 'dime') { acc += 10; }

      document.getElementById("msg2").innerHTML = "Your credit is: " + acc + " cents.";       

    } </script>

  <span id="msg1"> Welcome! </span> <p> 

  <span id="msg2"> Your credit is: 0 cents. </span> <p>  

  <form onSubmit="etupmoc('Bye'); return false;">

    Enter coin: <input type="text" name="coin"> <p> 

    <input type="submit" value="Deposit"> 

  </form>
</body></html>

import javax.servlet.*; 
import javax.servlet.http.*;
import java.io.*; 

public class Exam extends HttpServlet {
  public void doGet(HttpServletRequest request, 
                    HttpServletResponse response) 
                   throws ServletException, IOException 
  { PrintWriter w = response.getWriter(); 
    response.setContentType("text/html"); 
    w.println("<html><form>"); 

    String coin = request.getParameter("coin"); 
    String msg1 = ""; 
    if (coin == null) { msg1 = "Welcome. <p>"; } 
    else { msg1 = "You have typed: " + coin + "<p>"; } 

    int acc; 

    HttpSession s = request.getSession();  
    String credit = (String)s.getAttribute("tiderc"); 

    if (credit == null) { acc = 0; } 
    else { acc = Integer.parseInt(credit); } 

    if (coin == null) { acc += 0; } 
    else if (coin.equals("dime")) { acc += 10; } 
    else { 

    }

    s.setAttribute("tiderc", acc + ""); 

    w.println(msg1); 
    String msg2 = "Your credit is: " + acc + "<p>";
    w.println(msg2); 
    w.println("Enter coin: <input type=\"text\" name=\"coin\"> <p>"); 
    w.println("<input type=\"submit\">");    
    w.println("</form></html>");     
  }
}
There's a help session tonight (Wednesday) from 6:30-8:30pm in LH102.

Notes for Monday posted (contain GenericClient and HTTPServer)

Tue Aug 6
Here's the exam you took today, with answers (in blue).

Mon Aug 5
Click here to schedule an appointment.

Lab today has been moved to SB221.

Fri Aug 2
Here's the plan for next week:

  1. Monday the Practical Exam problem is announced.

  2. You start working on it on Monday and need to have it done by Thursday 5pm.

  3. Let's move the written exam on Tuesday.

  4. This way we can review some more on Monday, perhaps.

  5. Catch-up Day is Wednesday Aug 7 (Seven), this semester.

  6. On Catch-Up Day all Homework Assignments need to be finished.

  7. Individual appointments will be made sometime next week.

  8. I will post scheduler script on Sun so you can make an appointment.

  9. I anticipate most appointments will be on Fri, but all days are open.

  10. Check the help posted for Homework 5 and 6 below.

Thu Aug  1
Here's some help with the last homework assignment:
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.

Please look carefully at the programs so you don't take either one of them for an incorrect, not working program. They both work, but you need to be skilled in obtaining what you need from both of them. And you also need to finish them.

Wed Jul 31
Lab notes for this week posted, late at night.

Tue Jul 30
QuizSite now contains three simple, short review quizzes (dgerman-A348).

Mon Jul 29
Lab notes for today have been posted.

Text of Homework Five and Six to be posted tonight.

Sun Jul 28
Here's the list of folders in my installation:
burrowww.cs.indiana.edu% pwd
/nfs/paca/home/user1/dgerman
burrowww.cs.indiana.edu% ls -ld ~/tomcat/*/*
-rw-r--r--   1 dgerman  4568 Jun 11 00:09 [...]/LICENSE
-rw-r--r--   1 dgerman  3084 Jun 11 00:09 [...]/README.txt
-rw-r--r--   1 dgerman  2358 Jun 11 00:09 [...]/RELEASE-NOTES-4.0*.txt
-rw-r--r--   1 dgerman  2548 Jun 11 00:09 [...]/RELEASE-PLAN-4.0.1.txt
-rw-r--r--   1 dgerman  2683 Jun 11 00:09 [...]/RELEASE-PLAN-4.0.txt
-rw-r--r--   1 dgerman  5955 Jun 11 00:09 [...]/RUNNING.txt
drwxr-xr-x   2 dgerman   512 Jun 11 00:09 [...]/bin
drwxr-xr-x   2 dgerman   512 Jun 11 00:09 [...]/classes
drwxr-xr-x   4 dgerman   512 Jun 11 00:09 [...]/common
drwxr-xr-x   2 dgerman   512 Jul 25 10:45 [...]/conf
drwxr-xr-x   2 dgerman   512 Jun 11 00:09 [...]/lib
drwxr-xr-x   2 dgerman   512 Jul 27 22:33 [...]/logs
drwxr-xr-x   4 dgerman   512 Jun 11 00:09 [...]/server
drwxr-xr-x   2 dgerman   512 Jul 27 22:33 [...]/temp
drwxr-xr-x   7 dgerman   512 Jun 11 00:09 [...]/webapps
drwxr-xr-x   3 dgerman   512 Jul 25 10:47 [...]/work
burrowww.cs.indiana.edu% 
When you're done installing Tomcat please:

  1. check the servlet examples provided (listed on your Tomcat page)
  2. check the JSP examples provided (listed on your Tomcat page)
  3. change your Tomcat (home)page to include your name or username

Sat Jul 27
A note on your Tomcat installation: You Can Do It!

And a brief summary of the more salient features:

  1. The file I have in my public folder is
    burrowww.cs.indiana.edu% pwd
    /nfs/paca/home/user1/dgerman/public
    burrowww.cs.indiana.edu% ls -ld jaka*
    -rw-r--r--   1 dgerman  faculty   4241667 Jul 25 08:54 jakarta-tomcat-4.0.4.tar.gz
    burrowww.cs.indiana.edu%
  2. I use gunzip on it, I then tar xvf it, with
    burrowww.cs.indiana.edu% which tar 
    /usr/local/gnu/bin/tar
    burrowww.cs.indiana.edu%
    and I don't get any checksum error. No I don't.

  3. Note that it's version 4.0.4, extension .gz, and that I use GNU's tar.

If you need help please let me know.

Fri Jul 26
Lecture Notes Twenty-One have been finished.

They now provide EVERYTHING that's needed to finish Homework Four.

Thu Jul 25
server.xml.username files have been generated in /u/dgerman/public/a348/tomcats for everybody.
burrowww.cs.indiana.edu% pwd
/nfs/paca/home/user1/dgerman/public/a348/tomcats
burrowww.cs.indiana.edu% ls -ld server*
-rw-r--r--   1 dgerman  2765 Jul 25 11:22 server.xml.
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.aaeveret
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.ajflynn
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.ajstrain
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.bfonde
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.blayden
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.bmartins
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.bminton
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.cstucker
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.dgerman
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.dwhitmor
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.ggrumbli
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.heyoon
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.jihong
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.jmbennet
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.jvorwald
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.kgleason
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.kstanley
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.kwittste
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.mbuulolo
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.mchablan
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.mmccrack
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.mngantun
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.mrock
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.nbahri
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.pksander
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.rwgeorge
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.ryaosbor
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.shlgrego
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.sizhao
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.sshayan
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.taajones
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.tizhang
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.tthaker
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.wflint
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.yjchang
-rw-r--r--   1 dgerman  2774 Jul 25 11:23 server.xml.yli
burrowww.cs.indiana.edu%
Please let me know if you run into any trouble when you try to use them.

Wed Jul 24
Midterm grades, minute papers count have been posted (A348-4999).

Mon Jul 22
Notes for tomorrow have been updated. Homework Four is due a bit later now.

Here's a potential solution to part of your lab assignment:

<?
    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); 

            }


    } 
 ?>

Fri Jul 19
Grades for the midterm will likely be posted only Sunday night.

Thu Jul 18
Please read these notes about the project.

Wed Jul 17
Notes for this week updated.

Long overdue list of useful books (so far):

Tue Jul 16
Notes for today posted, announce lab assignment, start you on the possible project no. 2.

Mon Jul 15
I believe I caught up with the notes for last week. I also posted Lab Notes Seven (for today) and Homework Assignments Three and Four. One can already solve Homework Three, but not quite yet Homework Four (but in a couple of days Homework Four should also be easy to implement, by the time we are done with Homework Three, that is).

Thu Jul 11
There is a midterm exam in class today. During the lab, you will get the exams back for the entire duration of the lab to work with them. Your implementation is due on Monday July 15 at 5pm, and should be posted on your web server with the homework assignments.

Tue Jul  9
Here's the program we developed during the help session today (6:30-8:30pm):

#!/usr/bin/perl

&printHeader;

&readParse; # builds, or tries to build, an %in 

if ($ENV{REQUEST_METHOD} eq 'GET') {

  $in{number} = int(rand(100)); 
  $in{tries} = 0; 
  $message = "The game has started."; 

} else { # assume POST 
  if (!$in{number}) {
    $in{number} = int(rand(100)); 
    $in{tries} = 0; 
  }

  if ($in{guess} == $in{number}) { print "You win.\n"; &printTrailer; exit; }
  $message = "Try lower"; 
  $message = "Try higher" unless $in{guess} > $in{number}; 
  $in{tries} += 1; 
  if ($in{tries} >= 10) { print "You lost.\n"; &printTrailer; exit; } 

} 

  print qq{ 
    <form method="POST" action="$ENV{SCRIPT_NAME}">
      Please enter a number: <input type="text" name="guess" size=4> <p> 
      <input type="hidden" name="number" value="$in{number}"> 
      <input type="hidden" name="tries" value="$in{tries}">

      <p> $message You have used $in{tries} tries thus far. 

      <p> (The secret number is $in{number}) <p> 
      When done please <input type="submit" value="Click Me!"> 
    </form>
  };

&printTrailer; 

sub printHeader  { print "Content-type: text/html\n\n<html><body>"; } 

sub printTrailer { print "</body></html>"; }

sub readParse {
    if      ($ENV{"REQUEST_METHOD"} eq 'GET' ) {
        $input = $ENV{"QUERY_STRING"}; 
    } elsif ($ENV{"REQUEST_METHOD"} eq 'POST') {

        read (STDIN, $input, $ENV{"CONTENT_LENGTH"}); 

    } else {
        print "Unsupported method."; 
        &printTrailer; 
        exit; 
    } 

    @input = split(/\&/, $input); 

    foreach $elem (@input) {
        $elem =~ s/\+/ /g; 
        $elem =~ s/%(..)/chr(hex($1))/ge;
        ($key, $value) = split(/\=/, $elem); 
        $in{$key} = $value; 
    } 
} 
My PHP has been installed at 11:00am.

Help session tonight at 6:30pm in LH102.

There's an exam on Thursday, in class, at 9:30am. Here's what you might want to look into while I prepare the notes for this week, and post more info about the exam:

  1. Spring 2002 Midterm Exam

  2. An example of a problem you might see on the exam.

  3. A rough draft of the introduction to PHP from Spring 2002

  4. Fall 2000 Midterm exam with solutions.

  5. Fall 1999 Midterm exam.

Sat Jul  6
Notes for the week that ends today have been finally finished.

These notes are somewhat special: they bring a lot of information and explanations are extremely detailed. Please look at them as an example of complexity that an A348 semester project should exhibit (especially the server side technique, second set of notes).

Thu Jul  4
New set of notes (keeping state with SQL), almost done, not finished yet.

Tue Jul  2
Lecture Notes Nine have been finished.

Here's the Java code we wrote in class today:

// One.java, only illustrating how we set up the I/O connection 

import java.io.*;

class One {
  public static void main(String[] args) throws IOException {
    BufferedReader phone = 
      new BufferedReader(new InputStreamReader(System.in)); 
    System.out.print("Type something: ");
    String line = phone.readLine(); 
    System.out.println("You typed: " + line);  
  }
}

// Two.java illustrating the basic calculations

class Two {
  public static void main(String[] args) {
    int acc = 0; 
    System.out.println(acc); 
    // user says add 5 and we understand it 
    int arg = 5; 
    acc += arg; 
    System.out.println(acc); 
    // user says sub 3 ...
    arg = 3; 
    acc -= 3; 
    System.out.println(acc); 
    // and so on ... 
  }
}

// Three.java, that uses objects to implement the same thing 

class Acc {
  double balance; 
  void add(double arg) {
    balance = balance + arg; 
  }
  void sub(double arg) {
    balance = balance - arg; 
  }
  double show() {
    return balance; 
  }  
  // Acc() { } 
}

class Three {
  public static void main(String[] args) {
    Acc one = new Acc(); 
    System.out.println(one.show()); 
    one.add(5); 
    System.out.println(one.show()); 
    one.sub(2); 
    System.out.println(one.show());     
  }
}

// From here on we went into the Lab Notes (Five) 
First part of the first part of the notes on keeping state posted.

Program is included but more yet is to come, especially more explanations.

Mon Jul  1
Today in class we will discuss Lab Notes Five and finish the material from last week. This week's material is under development, here's where it starts, and here's the first prototype program for discussion (still under development).

Sat Jun 29
Text and official coordinates (due date included) for Homework Two posted.

Thu Jun 27
Lab notes for today have been posted introduce you to MySQL.

Here's the simple (standalone, to be used from the Unix prompt) calculator we wrote in class today:

#!/usr/bin/perl

$acc = 0; 
print "Hello, your account is: ", $acc, "\n"; 

while ($line = <STDIN>) {
  if ($line =~ /^bye/i) { last; }  
  if ($line =~ /^add (\d+)/) {
    $acc += $1; 
  } elsif ($line =~ /^sub (\d+)/) {
    $acc -= $1; 
  } else { print "I am sorry I don't understand $line."; } 

  print "The account now is: ", $acc, "\n"; 
}

print "Thanks for using this program.\n"; 

Wed Jun 26
Lecture notes for today posted.

Mon Jun 24
Office hours for Shakila have changed a little bit.

Also, here's the script we developed in class today:

#!/usr/bin/perl

print "Content-type: text/html\n\n"; 

print qq{<html><head><title>Experiment</title></head><body bgcolor="white">}; 

foreach $key (keys %ENV) {
  print $key, " --> ", $ENV{$key}, "\n<br>"; 
}

print "</body></html>";

Sun Jun 23
Notes for tomorrow and Tuesday posted.

Prototype for Homework One also updated.

Here's the script we developed in class last Thursday:

#!/usr/bin/perl

print "Content-type: text/html\n\n"; 

$date = localtime;

print qq{

<html>

 <head> <title>My First Script</title> </head>

 <body bgcolor="white">

    <h1>Hello! </h1>

    <font size=+6>It's $date. </font>

 </body>

</html>

}; 

Thu Jun 20
Web site structure has been updated to reflect current semester.

Wed Jun 19
Here's the list of ports to be used this semester.

Please let me know if any of them doesn't work for you.

Also here are our office hours.

Tue Jun 18
Just a reminder we should continue to use the Class Notes pages from Spring one more day.

Mon Jun 17
Welcome to A348!

For 2-3 days we will be using the notes from the Spring semester for lecture and labs, after that I will update the website to contain notes that I will be writing especially for this summer course. (These new notes will, of course, include most of the material covered last semester, but new material will be added, and the old material will be presented in a new form(at)).


Updated by Adrian German for A348/A548