The following two CGI Perl scripts will be given in the exam:
#!/bin/sh
PATH=$PATH:/home/Agassiz:/usr/java/bin:/usr/java/sdk/bin
CLASSPATH=.:/home/Agassiz/project/oracle/OraHome1/jre/1.1.8
CLASSPATH=$CLASSPATH:/home/Agassiz/project/oracle/OraHome1/jlib
CLASSPATH=$CLASSPATH:/home/Agassiz/project/oracle/OraHome1/jdbc/lib/classes12.zip
CLASSPATH=$CLASSPATH:/home/Agassiz/project/oracle/OraHome1/jdbc/lib/nls_charset12.zip
CLASSPATH=$CLASSPATH:/home/Agassiz/project/oracle/OraHome1/sqlj/lib/runtime.zip
CLASSPATH=$CLASSPATH:/home/Agassiz/project/oracle/OraHome1/sqlj/lib/translator.zip
CLASSPATH=$CLASSPATH:/home/Agassiz/project/oracle/OraHome1/ord/jlib
CLASSPATH=$CLASSPATH:/home/Agassiz/project/oracle/OraHome1/ord/ts/jlib
CLASSPATH=$CLASSPATH:/home/Agassiz/project/oracle/OraHome1/rdbms/jlib
CLASSPATH=$CLASSPATH:/usr/j2se/bin
export CLASSPATH
perl exam.pl
#!/usr/bin/perl
print "Content-type: text/vnd.wap.wml \n\n";
print "<?xml version=\"1.0\"?>\n";
print "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\""
. " \"http://www.wapforum.org/DTD/wml_1.2.xml\">\n";
read( STDIN, $buffer, $ENV{'CONTENT_LENGTH'} );
@pairs = split( /&/, $buffer );
foreach $pair ( @pairs ) {
($name, $value) = split( /=/, $pair );
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/~!/ ~!/g;
$FORM{$name} = $value;
}
The top part of a JDBC program will be given.
import java.sql.*;
import java.io.*;
class ClassName {
public static void main ( String args[ ] )
throws SQLException {
DriverManager.registerDriver( new oracle.jdbc.driver.OracleDriver( ) );
Connection conn = DriverManager.getConnection(
"jdbc:oracle:thin:@172.20.2.253:1521:aero", "userid", "password" );
try {
// Read the first parameter a1 from the file p1.
FileInputStream stream1 = new FileInputStream( "p1" );
InputStreamReader iStrReader1 = new InputStreamReader( stream1 );
BufferedReader reader1 = new BufferedReader( iStrReader1 );
String a1 = reader1.readLine( );
if ( a1 == null ) a1 = "";
else a1 = a1.trim( );
stream1.close( );
// Read the third parameter a2 from the file p2.
FileInputStream stream2 = new FileInputStream( "p2" );
InputStreamReader iStrReader2 = new InputStreamReader( stream2 );
BufferedReader reader2 = new BufferedReader( iStrReader2 );
String a2 = "";
while ( true ) {
String line = reader2.readLine( );
if ( line == null ) break;
a2 += line + "\n";
}
if ( a2 == null ) a2 = "";
else a2 = a2.trim( );
stream2.close( );