FAQ for the TDDB37 Labs

Q: There is no web server on zaza1.ida.liu.se.
A: Start it on your own machine as described in the first lab assignment.

Q: I suspect that the servers are down.
A: For the 2nd assignment, you can check yourselves whether the servers are up, by trying to connect to them with telnet (like in the examples presented on the lesson slides, pages 19-20). For the CORBA assignments, the simplest way is to ask by sending an email to the course assistant.

Q: I get an "Internal Server Error" message.
A: There are two reasons you got this message. Your CGI program crashed before finishing the output to the web browser or, you didn't output the Content-type correctly: "Content-type: text/html\n\n". Please note the two newlines.

Q: I get an error message when I compile the sockets example in C.
A: When you download the Makefile, tabs are replaced with spaces. Just replace back the spaces with tabs, for example:

server.o: server.c
<TAB>gcc -c server.c

Q: I want to use POST instead of GET. How do I do that?
A: Read the query string (it has the same format as for GET) from the standard input: read(0, buffer, size). The size is given in the CONTENT_LENGTH environment variable. More details are available here.

Q: I cannot print the title of the cards on the webpage. It works with Mozilla, but not with Netscape.
A: Read again the specification of the communication protocol for the CardDatabaseServer and verify whether you took care of the '\0' character which is sent after each reply from the server.

Q: I can't communicate with the CardWriteServer. It works when I use telnet, but my servlet program keeps receiving error messages.
A: If you are sending commands to the server with println(string), then you should be aware of the fact that such instructions will write the sequence of characters '\r\n' after the string. The server is written in C and it will not ignore the '\r' character. As a result, the server will not be able to match the request with its list of known commands and it will reply with an error message. Instead, you should send the commands using such a construction: print(string + '\n');

Q: I can't communicate with the CardWriteServer. It works when I use telnet, but not from my CGI program.
A: CardWriteServer is written in Java and uses readLine() to read a message from the client. You should not send the '\0' string termination character, but only the string itself with the new line caracter '\n'. For example use write(socket, string, strlen(string)) and not write(socket, string, strlen(string) + 1)). Don't forget about the new line at the end of the string.

Q: I want to do the labs at home or somewhere else, not in the SU labs.
A: For the first lab: just load the pages in netscape, with File > Open Page... For the second lab (with CGI): start the web server on remote-und/astmatix.ida.liu.se; develop your CGI programs (edit, compile) remotely in your account at IDA; test them with netscape from home by connecting to remote-und where you started the web server. For the 2nd lab with servlets: the same as for the CGI variant, but start the servlet runner instead of the web server.

Q: When I start the servlet runner I get the "java.net.BindException: Address already in use" error message.
A: There is another web server or servlet runner running at the port 8080. Change the port number with the -p flag (--help for all the flags).

Q: It seems I can't output Strings from the servlet using out.println().
A: The Strings should NOT contain the null character '\0' at the end.

Q: When I run jidl I get an error saying that the libstdc++.so.5 library is missing.
A: Make sure you have loaded the module prog/gcc/3.2.0 in your current environment.

Q: How can I reuse the CGI interface for the CORBA client?
A: First, you will need to specify in the source file the parameters for initialisation of the ORB. Second, you will need to compile everything using the -static flag, which does not allow the use of shared libraries. Unfortunately, you will not be able to compile your program in this way because there are several libraries which are provided only for dynamic linking.

Q: When I test my CORBA server, I get an org.omg.CosNaming.NamingContextPackage.AlreadyBound exception.
A: This is because the name which you used to register your Database object in the NameService is still bound. You have several alternatives:

Q: How can I use the ORBacus ORB rather than the default Sun ORB included in JDK 1.2?
A: To use the ORBacus ORB instead of the ORB included with JDK 1.2, you must start your application with the following properties:

java -Dorg.omg.CORBA.ORBClass=com.ooc.CORBA.ORB \
     -Dorg.omg.CORBA.ORBSingletonClass=com.ooc.CORBA.ORBSingleton \
     MyApp

An alternative is to set these properties in your program before initializing the ORB. For example:

import org.omg.CORBA.*;
public static void main(String args[])
{
    java.util.Properties props = System.getProperties();
    props.put("org.omg.CORBA.ORBClass",
              "com.ooc.CORBA.ORB");
    props.put("org.omg.CORBA.ORBSingletonClass",
              "com.ooc.CORBA.ORBSingleton");
    System.setProperties(props);

    ORB orb = ORB.init(args, props);
    // ...
}

For Applets, you can use Applet parameters:

<APPLET ...>
    <PARAM NAME="org.omg.CORBA.ORBClass"
     VALUE="com.ooc.CORBA.ORB">
    <PARAM NAME="org.omg.CORBA.ORBSingletonClass"
     VALUE="com.ooc.CORBA.ORBSingleton">
</APPLET>

For more information see: http://java.sun.com/products/jdk/1.2/docs/api/org/omg/CORBA/ORB.html

Q: How can I test my applet? Nothing seems to work.
A: Most of the trouble with testing an applet comes from the "applet security" concepts. An applet is not allowed to do everything it wants on your machine because of security concerns.

Netscape: Netscape does not allow an applet to connect to a different machine than the one which served the applet. Thus, you can't connect from your applet to CardDatabase (on mir53.ida.liu.se) and CardWriter (on mir59.ida.liu.se) servers:

netscape.security.AppletSecurityException: 
security.Couldn't connect to 'mir53.ida.liu.se' with origin from 'www.ida.liu.se'.

appletviewer: You can test your applet with the applet viewer:

appletviewer file.html
However, if you are using JDK 1.2 then I personally couldn't find a way to tell the applet to use ORBacus instead of the ORB which comes with the JDK 1.2. It seems that the appletviewer doesn't know how to interpret the special parameters given to the applet.

Internet Explorer: Internet Explorer (on the SUN machines at IDA) seems to spawn the appletviewer in order to execute applets. All said before about the appletviewer applies here too.

HotJava: HotJava is a browser written in Java from SUN. My advice is to use HotJava in order to test your applet. This solution seems to be the most convenient because it doesn't impose security restrictions as Netscape and doesn't have the problems of the appletviewer. Use HotJava like this:

hotjava file:/<complete path to file>/client.html

You have an applet example below which you can use as a reference:

A final note: If you serv the applet over the network from a webserver (and not locally from your file system), then you'll have to replace in the client.html the archive parameter with archive="OB.jar" and make available (i.e. copy) the OB.jar in the same directory with the applet code.