Cracking the Lab! – 1

Being in the seventh semester has had its pros and cons. However, the labs in this semester haven’t been a good experience, in terms of all the trouble we had to go through just to get the software work at our home PCs for practice. I have tried hard and come close to what you might say, “a working” situation, where everything seems to work for me. Here are the steps I had to take to arrive at this very metastable state, you could try and follow the steps below to make things work for you; however, I do not guarantee that it will always work.

Also, here is the code for the programs I have written. Download it here. (Note: For database related programs, you will have to properly create databases/tables for it to work)

1. Fedora + Apache (for Perl, CGI, PHP, MySQL)

Get the latest fedora from and install it using all the packages selected (this is the safest way to do it; but if you know exactly what you are doing, you are free to select the right packages)

Once you are booted into Fedora, login using the root account (always do this – since you are on localhost, security should not be a problem for you.) and run apache and mysql.

  • Select “System” from the main menu, then click on “Services” in “Administration”.
  • Browse through the list and start (and enable) the “httpd” and “mysqld” services.
  • Now run the browser and point it to “http://localhost” to see if the apache service has started successfully. If it has, you will be able to see a Fedora Start Page in your browser.

You are now finished configuring. For working with apache you’ll have to know the following:

  • All “*.html, *.php, *. htm, *.shtml, *.xhtml” files go in “/var/www/html” directory.
  • All “*.pl, *.cgi” files go in “/var/www/cgi-bin” directory.
  • You’ll have to make the *.cgi, *.pl files executable by right-clicking on them and setting the permissions in their properties or by simply using the command in a terminal: “chmod 777 /var/www/cgi-bin/filename.cgi
  • If you find yourself looking at the “500 – Server Error” page, you might want to look into the logs to debug your errors. The logs are found at “/etc/httpd/logs/”

2. Tomcat + Java (for Java Servlet programming)

Get the JDK from the Java website here. And Apache Tomcat from here. Log into an account with administrative privileges and install them. Once you have installed both of them, you will need to set a few environment variables before you can start writing/compiling the code. I’m assuming that you have installed Java at “D:\j2sdk” and Tomcat at “D:\Tomcat”. (Make necessary changes in the below values as per your installation directories)

Variable Name


PATH D:\j2sdk\bin
CLASSPATH D:\Tomcat\common\lib\servlet-api.jar

You can set these variables by, right-clicking on “My Computer”. Then, choose “Properties”, and in the “Advanced” tab, click on “Environment Variables”. If a variable by that name already exists, you can append the above value to it by using the delimiter semi-colon “;”.

Spot check! Write a sample Java code and try compiling it by opening Command Prompt (Start -> Run: “cmd.exe”) and using the following command: > javac

If you get any error stating that “javac” is a bad command or filename, then there is something wrong with your installation. Recheck the above steps again.

Start the Tomcat server: Start -> All Programs -> Apache Tomcat -> Configure Tomcat. Once the Tomcat tool is running, click “Start”.

Open your browser and point it to: “http://localhost:8080/”. If Tomcat has been properly installed, you will see default Apache Tomcat page. If not, recheck the above steps.

That’s (sadly) not all of the configurations that you have to change in order for things to work. Right now, you will be able to code in Java and also compile it. However, you will not be able to code servlets unless you change the default “web.xml” file or add a custom web.xml file for your servlet. I’m going to tell you how to modify the default web.xml file so that you can get things to work.

Open the web.xml file (Located at: D:\Tomcat\conf\web.xml) in a text editor, and look for the following codes and uncomment them. (Remove the ‘<!–‘ and ‘–>’ around the code)


And this:


!!! One piece of warning !!! Uncommenting these lines will prove to be a security threat if you are doing it on a commercial web server. You shouldn’t really worry about it if you are using it at your home computer.

Once you are done with the above steps, you can be glad to know that nothing stands between you and coding the servlets now. (Phew!) Anyhow, you must know these for the things to actually work: (I’m assuming that you will be using the “ROOT” directory for your servlets, if not, make changes in the following paths accordingly)

  • All the “*.class” files go into “D:\Tomcat\webapps\ROOT\WEB-INF\classes” directory.
  • All “*.html, *.jsp, *.htm, *.shtml, *.xhtml” files go into “D:\Tomcat\webapps\ROOT” directory.
  • Use the “javac.exe” application (in “D:\j2sdk\bin”) to compile your code, which will create a classname.class file for you.
  • Now copy the .class to the classes directory and you can access the servlet using “http://localhost:8080/servlet/classname

Well, that’s it for now. Its sad that we have to go through all this just to practice five programs for our labs. Anyway, I hope all the settings work for you. If not, let me know; I hope I can help you.

P.S: Configuration for Networks Lab (Fedora + NCTUns) will be out tomorrow. 🙂


Unexpected Road Trip!

Its so typical of the things that happen in life. They just spring up! Just like the road trip that we went on today. I took my bike to college today (Dad would normally not let me take it because of the traffic en route). After the first hour, we decided to bunk the rest of the day and go on a road trip! No petrol. Not much of cash. And yet, we leave! Four bikers (Pele, Virus, Kage and me) and four others (Hulee, Bottle, Baby and Piggy). We fill little petrol on the way, just in case.

Firstly, we reached the Hesarghatta lake — a lake which is no more. 😦 But the scenery was amazing! There was an old well, which we climbed down into and took snaps (on Kage’s mobile). Later, we went to a temple nearby. Then we decided to go to Nrityagram which is about 3.5 KM off the main road. We reached there to find it closed, and the watchman informed us that it will be open only from 6th May. We took a few more snaps there and headed back to the main road. Once we reached there, we stopped again to take a few pictures at a eucalyptus grove. There, we chose not go back to college (our lab was rescheduled to take place earlier that day; and even if we tried to return, we couldn’t have done so in time), instead, we went further to the Madhure temple (about 15 KM farther). The roads weren’t really ‘pleasant’ to drive on but we were all thrilled and it did not matter a thing! On the way, we also went to another temple — Veeranjaneya temple. Upon reaching the Madhure temple, it was about 1PM. We had the darshan of the deity and Virus had his bike worshiped. Everyone was dead hungry. I hadn’t eaten anything since morning!

From there, we decided to return via the highway through Nelamangala. On the way, we stopped at Jyothi Dhaba to have our lunch. The food wasn’t all that tasty but we hogged nicely. 🙂 The highway ride on the way back was amazing! Baby was riding pillion and we touched 108 KM/Hr on my bike! Hulee and Pele, (on Pele’s brother’s bike) also touched 107 KM/Hr. It was 4PM by the time I came back home. Totally spent, dirty, and sleepy! Mom scolded me when I told her about my speedy feat. 🙂 Its so nice to see my Mom all worked up and irritated with me when I end up doing silly things. The look on her face is priceless! 🙂

Too bad I couldn’t sleep then. Bluemistwar had called (and my cell had no network!) and I got his messages after I reached home. I headed to Kss’s place right then. I came back by around 6PM and slept till 8PM! 🙂

One amazing day! 🙂