![]() |
![]() Fall Semester 2007 |
Sat-Sun Dec 08-09Code developed in lab yesterday with Mike Jindra and Aaron Ofengender. So, what about it?
Fri Dec 07
<%
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>
Thu Dec 06Chapter 13 code, code from Tue class, will show up here soon.
Wed Dec 05
Here's the script to make individual appointments.
Fri Nov 30The code below would be my contribution. What do you think of it?
<?
if ($fl_gs) {
$flags = explode(',', $fl_gs);
$flaeg = array_pop($flags);
$flags = implode(',', $flags);
} else {
$initial = array("one", "two", "three");
shuffle($initial);
$flags = implode(',', $initial);
}
?>
<form>
<font color="#0066cc"><?=$flaeg?></font>
<input type="submit" value="Proceed">
<input type="hidden" name="fl_gs" value="<?=$flags?>">
</form>
JDBC notes from the past.
Thu Nov 29
we develop a simplesouffle.jspin web context$CATALINA_HOME/webbaps/1127
these two files get created:So the conclusion is: there's a servlet behind every JSP.$CATALINA_HOME/work/Catalina/localhost/1127/org/apache/jsp/souffle_jsp.class $CATALINA_HOME/work/Catalina/localhost/1127/org/apache/jsp/souffle_jsp.java
shuffle.jsp into a servlet (Shuffle.java)
Shoofle.java)
shoofle.jsp)
Wed Nov 28Recall the project blog, notes for homework three already have what you need.
The new thing in the link above is just the format of this data, text here.
Getting data in, and out of the database (you've seen these scripts before).
Mon-Tue Nov 26-27Labs this week: JDBC from servlets.
Next week: project concludes with a discussion of multi-screen apps (ch. 13 in text).
Wed-Sun Nov 21-25
Mon-Tue Nov 19-20
Sat-Sun Nov 10-18
Fri Nov 9
Tue-Thu Nov 6-8Notes to be used today in class:
Once this is done we can look at an older project:
Relevant for the lab this week:
classes folder
web.xml for the servlet
A JSP that implements the Flag Quiz.
Thu-Fri Nov 1-2
Wed Oct 31
Tue Oct 30Please read chapters 17, 16, 18 in your text.
Sat-Sun Oct 27-28
Fri Oct 26
Thu Oct 25Lab Notes for this week.
Here's an example from Chapter 15, and another one from the same chapter.
More code, and some more (simple examples the lab could discuss).
Thu Oct 18
Tue Oct 16
Fri-Mon Oct 13-15
Thu Oct 11Here's a program you might want to develop three ways (CGI/Perl hidden, PHP with and without sessions).
Fri-Wed Oct 5-10All links in the material for the lab last week work now.
Tue-Thu Oct 2-4Materials for this week's lab are to be found here.
Sat-Mon Sep 27 -Oct 01This week we give you an example. Take a look, here.
Wed-Fri Sep 26-28
Tue Sep 25
More to come soon, including Homework Three.
Mon Sep 24Basic framework we're trying to develop:
Sat-Sun Sep 22-23
Fri Sep 21#!/usr/bin/perl
use DBI;
use CGI;
$q = new CGI;
print "Content-type: text/html\n\n";
$DB = "dbi:mysql:demoOne:silo.cs.indiana.edu:port=14518";
$username = "dgerman";
$password = "sp00n"; # put your own password, you can see mine if you highlight it
$dbh = DBI->connect($DB, $username, $password, {PrintError => 0})
|| die "Couldn't open database: ", $DBI::errstr;
$query = "select * from players";
$sth = $dbh->prepare($query) || die $dbh->errstr;
$sth->execute() || die $sth->errstr;
Programs that you might want to test your PHP with:
<? session_start();
if ($message) {
$balance += $amount;
$message = "Balance is currently: " . $balance;
} else { // initialize state
$message = "Balance is: ";
session_register("message");
$balance = 0;
$message .= $balance;
session_register("balance");
}
?>
<form>
<?=$message?> <p>
Amount to add: <input type="text" name="amount" size=4> <p>
Press <input type="submit" value="Proceed"> when ready.
</form>
This is similar to the one above, just uses client-side state:
<?
if ($message) {
$balance += $amount;
$message = "Balance is currently: " . $balance;
} else { // initialize state
$message = "Balance is: ";
$balance = 0;
$message .= $balance;
}
?>
<form>
<?=$message?> <p>
Amount to add: <input type="text" name="amount" size=4> <p>
Press <input type="submit" value="Proceed"> when ready.
<input type="hidden" name="message" value="$message">
<input type="hidden" name="balance" value="$balance">
</form>
We will explain them both, very thoroughly this coming week.
Wed-Thu Sep 19-20
Here's some code you could use directly:
The two lines you need to add to./configure \ --with-mysql=/nobackup/dgerman/mysql \ --with-apxs2=/u/dgerman/apache/bin/apxs \ --with-config-file-path=/u/dgerman/apache/conf \ --with-xml --enable-track-vars \ --prefix=/u/dgerman/apache
httpd.conf:
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
The notes on the class notes page will not add much more to what's posted here.
Tue Sep 18mysql_start batch file:
--log-error=/nobackup/dgerman/mysqld-error.log \
Careful to put your username instead of mine.
Sat-Mon Sep 15-17Steps for installing MySQL: one, two, three, four.
Another set of notes with a shorter sequence of steps.
More to come soon.
Tue-Fri Sep 11-14Steps for installing a protected folder: one, two.
Code we developed in class on Thu: one, counter.Program that should be relevant to Homework Two: shuffle (see it running here).
Sample programs we are interested in this week:
Sat-Mon Sep 8-10
Sat-Mon Sep 8-10
Fri Sep 7
Thu Sep 6My office hours, as a reminder: MTWRF 10:00-11:30am in LH201D.
Wed Sep 5
Tue Sep 4
Here's the command prompt calculator:
#!/usr/bin/perl
$balance = 0;
print "Your balance is: $balance\n";
print "Type> ";
while ($line = <STDIN>) {
chop($line);
($fun, $arg) = split(/ /, $line, 2);
print "You want to $fun a value of $arg to the balance of $balance.\n";
if ($fun =~ /^add/i) {
$balance += $arg;
} elsif ($fun =~ /^sub/i) {
$balance -= $arg;
} else {
print "I am sorry I don't understand $fun.";
}
print "The balance is now: ", $balance, "\n";
print "Type> ";
}
Here's the program that reports the time, as well the contents of hashtable %ENV:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
$time = localtime;
print "Hello! The time is now: $time";
foreach $key (keys %ENV) {
print $key, " --> ", $ENV{$key}, "<br>";
}
Wed Aug 29Notes for this week have been posted.
Tue Aug 28Adrian's office hours:
Teaching assistant for this class: Ms. Shakila Shayan (office hours to be announced soon).
Required text for this class (avalable at IU Bookstore).
List of students and ports. Basic syllabus (specific details forthcoming).