Download as pdf or txt
Download as pdf or txt
You are on page 1of 33

Gear Up To TGMC- Part I |2

Title Chapter 1 Understanding the Web Why TGMC? Scope of this tutorial A Brief History What is a web site? Types of web sites How web sites work? What softwares are to be used? What software for what? A Few Exercises Chapter 2
Introduction to DB2

CONTENTS Page Title A Few Exercises 3 3 3 4 4 5 5 6 6 Chapter 5 Installation in Linux Why Linux? Installation issues in Linux Installing JAVA SDK Installing WASCE Installing Eclipse Installing DB2 Express C Conclusion A Few Exercises Our Apologies to Tough Technocrats Acknowledgements A Prelude to Gear Up To TGMC Part II

Page 24

25 25 25 25 27 27 30 30 31

Introduction Tables DB2 Installation Starting & Stopping DB2 Creating a new database Create New Table Queries Where to test? Alternate Way Conclusion A Few Exercises Chapter 3 Introduction to WASCE Introduction Installing WASCE Starting & Stopping WASCE How WASCE works? Managing WASCE A Few Exercises Chapter 4 Introduction to Eclipse Introduction What is Eclipse? Installation of Eclipse Initial Steps What is a project? Adding content to a project

7 7 7 9 9 9 9 11 12 12 12

32 33

13 13 14 15 16 17

18 18 18 18 19 21

Gear Up To TGMC- Part I |3

Chapter I - Understanding the Web


Why TGMC? The Indian Universities produce lot of engineers every year. Most of them are employed in the software sector. After selection, the freshers are given a training to prepare them for the standards and practices of the industry. But, despite the trainings given, many companies find that the trained freshers are not as efficient and clear as they are expected to be. And, the curriculum offered by the universities is not enough to develop the problem-solving skills and creativity of the students. As a solution to this problem, International Business Machine (IBM) Corporation has started to educate the students regarding the software industry trends and to develop the problem-solving skills of the students. IBM has its IBM Academic Initiative especially for this purpose. The Great Mind Challenge is a part of IBM Academic Initiative. It aims at developing the ability of the students in Web Application Development using J2EE, Database Management, etc. Scope of this Tutorial (Part I) At the end of this part of tutorial, you will be able to Know the difference between static web site and a web application Manage data in a Database Server called DB2 Design a database for your own web application Install all required softwares in Linux A Brief History In the earlier days, the computer was not built to be used by individual persons. The computers were probably introduced early in the Banking Sector for the computation and storage of records. A single branch of a bank would have a single big computer, theoretically a single big CPU, called the SERVER. All the monitors and keyboards from the individual terminals would be connected to that server. All the commands given by the users would pass through this server and then the server would execute them. This is called Single Server- Multi Client Architecture. This was prevalent in the earlier days. The Clients in this architecture are called Dumb Terminals. As the usage of banks increased, the amount of data that needs to be stored in the server also increased. So, the people decided to store the data in a

Gear Up To TGMC- Part I |4 separate big computer called Database Server. Thus, the main server would perform calculations of the data fetched from the database server. As the usage of banks still more increased, the number of computations needed per second of the main server also increased. This demanded a new solution to the problem. Then came the computers with a single CPU, a single monitor and a single keyboard (mouse was not available then!!!), just like our PCs. These PCs (clients) are connected to a big main server via LAN. The main server is also connected to the database server. The people divided the necessary computational jobs into two categories as under: 1. Those, which need not be performed in the server 2. Those, which must be performed in the server. The first category computations were performed in the client side and the second category computations were performed in the server side. The computer applications developed in the time after the arrival of PCs were mostly stand-alone applications built with C, C++, Visual Basic, etc. Some network-based applications were also built in this period. These applications catered to the needs of a small network. In those times, any application required some software to be installed on the personal computer of the user. So, this needed a certain amount of disk space in the consumers computer. This proved to be a limitation as this restricts the number of applications a person can load in his computer. The advent of World Wide Web solved this problem. The applications began to be built as web applications (like e-ticketing, ebanking, etc.). This needed no software in the consumers (clients) system. The necessary software is installed only in the server. The client has to install only a browser in his system. This attracted many users and so the web applications are ruling the world now. What is a Web Site? A web site, technically, is a collection of inter-linked related web pages. For example, the web site of a university is nothing but a collection of the web pages regarding that university. Types of Web Sites There are two types of web sites, namely, 1. Static Web Sites 2. Dynamic Web Sites A school web site is a perfect example of a static web site because the content shown by the web site does not vary according to conditions. It will

Gear Up To TGMC- Part I |5 show the same pages to all users. In another words, the viewer can do nothing to change the information shown in the web site. The users dont visit these sites frequently as it does not provide any new information every time. A search engine is a perfect example of a dynamic web site. The content shown by the web site is changed according to the users input. A dynamic web site can be used for ticket reservation, shopping, email, etc. This attracts the users since the information keeps on changing. This is otherwise called as a Web Application. How websites work? The web sites are usually stored in a huge machine called SERVER, which is connected to the Internet. The server will have a domain name (like yahoo.com). There is a difference in the servers used for static and dynamic web sites. To understand this difference, let us first know what happens when we access a web site from Internet Explorer or some other browser. First, when we type any address like www.yahoo.com in a browser and press go, the browser sends a request to the remote yahoo server to send back its home page. The yahoo server receives this request and sends the home page of the web site to the client. The browser receives the home page and displays it to the user. Now, let us see the different types of servers needed for static and dynamic web sites. For a static web site, the servers only job is to process the HTTP request and send back the requested file to the client. The server, which can satisfy this requirement, is called a web server. For a dynamic web site otherwise known as a web application, the server has to perform computations based on the data given by the user. For example, if it is a login form, the server has to check whether the username and password are correct and return an appropriate message to the user. This needs some computational job to be performed in the server. A server, which can do computations and at the same time, do the job of the web server, is called an application server. What softwares are to be used? IBM has prescribed a certain set of softwares to be used for the web application development in TGMC. They are: Eclipse WebSphere Application Server Community Edition-WASCE (other name is Apache Geronimo) DB2 Express C

Gear Up To TGMC- Part I |6 What software for What? Dont get amazed with the names of the softwares. After a minute or two, you will be very familiar with the functionalities of them. First of all, we must know the functions to be performed and we have to relate the softwares with that function. In that way, the functions to be performed are: 1. Storage of data (like username and password of members) 2. Retrieval and processing of that data (like verifying the correctness of password and directing the user to a corresponding web page) Thus, we need to have two separate softwares to perform these functions. The storage of data is done with the help of a database server. The software called DB2 Express C (manufactured by IBM) serves as a database server. This database server stores the data and returns those data when requested. We use DB2 Express C as a database server. Then, we need a server that processes the data from the database server and does some job according to the conditions. In actual www business, the servers are very huge machines with very large computational capacity. But, being the developers with just a PC, we cannot afford to have a server. So, IBM has prepared a software, which acts like a server. It is a compressed form of the actual server software. It can be installed in any PC. This is nothing but the Websphere Application Server Community Edition (WASCE). Its another name is Apache Geronimo. This server understands a special language called Java Server Pages (JSP). This is a server-side programming language. This JSP is just like CPP. It is not much different from the CPP. And, if you know some Java, you can easily grasp it. For C and CPP, we have a software like Turbo C, which helps us to compile, debug and execute the CPP or C code. This software is called Turbo C++ IDE. IDE stands for Integrated Development Environment. Likewise, we need some IDE for writing and debugging the JSP code. This IDE is nothing but Eclipse. We hope that this chapter fed you with necessary basic knowledge regarding the web and an introduction to the softwares to be used in TGMC. A Few Exercises 1. Try to know what are the server-side programming languages available. 2. Visit any web site and try to know what server side programming language that site is using. For example, I want you to check what language does www.tgmc.in

Gear Up To TGMC- Part I |7

Chapter II Introduction to DB2


Introduction For any meaningful web application, database becomes an essential requirement. Database is nothing but a storehouse of data, in which we store the data. We can add more data to the existing database and also change the existing data or delete some of the existing data. We can also retrieve the data stored in a database and process them. We know that the processed data is called information. So, by processing the data retrieved from a database, we can present meaningful information to the user. Tables In a database, we store the data in terms of tables. A database can have many tables. Each table has columns, otherwise known as fields. For example, if I want to create a table to store the login information of all the users, the table would contain the following columns. Username (username of user) - Text Password (his/her password) - Text Status (whether he has logged in or not) Boolean (1 for logged, 0 for not logged) Now, I can assign one row to each of my users. For example, USERNAME Ram lakshman Seetha PASSWORD wordpass Brother Ram STATUS 0 1 0

Now, if I want to perform authentication for logging in, then my job becomes simple. I have to check whether a username like the one entered in the login form, is in the database with the same password. If it is found, then login is successful and I will change the Status value of that user to 1. Suppose if the user has already logged in, we can say that he is already logged in. DB2 Installation The installation of DB2 Express C can be the best with the default options in the installer. So, no change is needed in the installation except the following one. Note For Windows Vista Users: Note that you have to run the installer as Administrator. Or else, it may not create necessary services/instances needed for correct running of DB2. But, once after you install, you better login as the new db2admin user and run all things of

Gear Up To TGMC- Part I |8 your project. Take note of the fact that you have to run Control Center as Administrator. In the midst of the installation, the installer will ask for a username and password. Conventionally, the username is db2admin. You can specify the password of your choice. But, please make a note of this username and password in some place because, you need this for many future operations. After the installation is over, a new Windows user is created in your system as db2admin and the password for the same will be the one, which you gave during the installation. below. After installation, you will find a icon for DB2 in the system tray as shown

Now, the installation is successful in your computer.

Gear Up To TGMC- Part I |9 Starting and Stopping DB2 Note the red square in the DB2 icon in the system tray. It shows that the DB2 is not started in the system. To start DB2, right click that icon and select Start(DB2). Now, you can see that the red square in the icon is gone. Once the red square is gone, the DB2 database server becomes active. To stop the DB2 database server, right click the same icon and select Stop(DB2). Now, you can see a red square in the icon in the system tray. Creating a new database A new database can be created using DB2 Control Center. For this, follow these steps. Start DB2 Click on the DB2 icon and select DB2 Control Center Click on All Databases In the right bottom box, select Create New Database Now, a wizard will start. It will ask you the name of the database. Give the name of the database and Click Next upto the last stage. Now, you have database added in the All Databases box. Create New Table Follow these steps to create a new table. Click on All Databases Click on the database in which you want to create a table. Click on Tables. Click on Create New Table in the right bottom box. Create Table Wizard will be started. Give the Schema name as DB2ADMIN. (This is not required but it is better). Choose a name for the table and click next Add Columns according to the requirement. Then, click Next till the last stage and finish. Now, you have a new table in your database. Queries The tables of the database are accessed by means of special commands called queries. You can insert, update or delete the rows in a table. You can also view the contents of the table according to some criteria. 1. Insert Query The Insert Query is used to insert rows into a table. Syntax: INSERT INTO SCHEMA_NAME.TABLE_NAME (COLUMN1_NAME, COLUMN2_NAME,,COLUMNn_NAME) VALUES (VALUE1,VALUE2,,VALUEn) For example, the query below will insert a row into the table USERS in the schema DB2ADMIN.

G e a r U p T o T G M C - P a r t I | 10

INSERT INTO DB2ADMIN.USERS VALUES (ram,wordpass,0)

(USERNAME,PASSWORD,STATUS)

This query will add a new row with the username ram and password wordpass and status 0 (not logged in), as given in the first row of the table shown in the beginning of this chapter. 2. Select Query The select Query is used to fetch the rows of the table. Syntax: SELECT COLUMN1,COLUMN2,,COLUMNn SCHEMA_NAME.TABLE_NAME WHERE <CONDITION> FROM

For example, the query SELECT * FROM DB2ADMIN.USERS will return all the rows and columns in the table users. The query SELECT STATUS FROM DB2ADMIN.USERS WHERE USERNAME LIKE ram AND PASSWORD LIKE wordpass will return the status of the user ram with password wordpass from the table users. This can be used to verify whether a given username and password combination is correct or not. (We will see about this task later) 3. Update Query The update Query is used to change the values of some data in a table. Syntax: UPDATE SCHEMA_NAME.TABLE_NAME SET COLUMN1=VALUE1, COLUMN2=VALUE2,,COLUMNn=VALUEn WHERE <CONDITION> For example, the query UPDATE DB2ADMIN.USERS SET STATUS = 1 WHERE USERNAME LIKE ram AND PASSWORD LIKE wordpass will change the logged status of the user ram to 1. This is used after verifying that the given username and password are correct. This shows that the user is logged in. 4. Delete Query The delete query is used to delete a particular row in a table. Syntax: <CONDITION> DELETE FROM SCHEMA_NAME.TABLE_NAME WHERE

For example, the query DELETE FROM DB2ADMIN.USERS WHERE USERNAME LIKE ram will delete all the rows whose username column has a value ram.

G e a r U p T o T G M C - P a r t I | 11 Where to test? Believe it or not, we are going to use only these 4 queries repeatedly throughout the project. So, now you are good in queries. Let us move to the most important question of Where to write and test the queries?

DB2 provides a command editor for writing and testing a query. To go to that, click on the icon encircled in the above diagram. Now, a new window will open. In that, ; is the terminating character. It means that you have can type many queries and run them in a single click. But, each query has to be separated by a semicolon.

NOTE:- Give a statement CONNECT TO <DB_NAME> at the beginning in order to connect to your database where DB_NAME is the name of the database you created.

G e a r U p T o T G M C - P a r t I | 12 Now, you can type all your queries and run them by clicking the green right arrow button in the toolbar. Alternate Way: You can get an improved method of querying a table by double-clicking on the table name in the Control Center Window. This will open a window for adding, updating and deleting the rows in a table. Important Note: Dont forget to press commit before closing the window. Then only the changes will be implemented in the table. Conclusion Now, you know what are the operations that you can do on a database. So, think of the data which you will be storing in the database. Organize them as separate tables and decide upon the columns to be included in each table. Remember that a database can hold any number of tables. A Few Exercises 1. Collect data about what are the different ways of using a SELECT statement. 2. Propose a database design for maintaining the attendance of all the classes and sections in a school. (In this, you have to create many tables). And, if time permits, create a database for this and test all your SQL statements in it. 3. Observe the different data types (like integer, varchar, date) of columns of a table and experiment with them. In particular, I want you to experiment with DATE datatype. You should try all formats and know, in which format (dd-mm-yy or mm-dd-yy or anything else) date has to be stored in this column. 4. Try to observe many web sites and make guesses as to what their database would look like. That is, we want you to guess the tables and their columns. 5. If possible, design a database for use in your TGMC project, according to the scenario which you have chosen.

G e a r U p T o T G M C - P a r t I | 13

Chapter III - Introduction to WASCE


Introduction We have dealt with the concept of servers earlier. Let us stress some of those points here again. There are two classes of servers namely, Web Server (which can only transfer files but not do any computation) and Application Server (which can transfer files but also can do computation). WebSphere Application Server Community Edition (WASCE) is application server. It is otherwise called Apache Geronimo. uncompressed version of Apache Geronimo is called Apache Tomcat. cannot be installed and tested easily in our personal computers configurations. one such The full, But this with low

Actually, this is the software, which will act as an actual application server. So, now on, if we tell server, then you should understand that we mean this WASCE. Installing WASCE Installing WASCE is the quickest process you can do. But, there are some pre-requisites needed to install WASCE in your system. WASCE understands a language called Java Server Pages (JSP). For this, it needs Java SDK (Software Development Kit) to be installed somewhere in your system. So, your first step is installing JAVA SDK. But, there are many versions of JAVA available. Which one to install? The answer is here: When you run the WASCE installer, it will first ask for a place where JAVA is installed. In that screen, you can know the Version of JAVA needed by this copy of WASCE. WASCE 1.0 needs Java 1.4.2 and WASCE 2.0 needs Java 1.5 CAUTION:- Please check with the JAVA SDK version that is needed by the WASCE copy that you possess and then install the same. For example, if your WASCE needs Java 1.4.2, dont install any version other than Java 1.4.2. JAVA SDK can be downloaded from the internet free of cost. If you are done with the installation of JAVA, you can proceed to the WASCE installation. Note For Windows Vista Users: Note that you have to run the WASCE and JAVA SDK installer as Administrator.

G e a r U p T o T G M C - P a r t I | 14 Dont change anything in the installation wizard. Just accept the Default options (except, of course, you should accept the license agreement.). This will install WASCE in your system. Starting and Stopping WASCE To start WASCE, do the following Go to Start Menu - > Programs Click on IBM WebSphere - > Application Server Community Edition Click on Start the server. You will see a window, in which many configurations are loaded one by one.

At last, it will print Geronimo Application Server Started. Now, your WASCE is started.

G e a r U p T o T G M C - P a r t I | 15 Caution:- Dont close this window as long as you are working with WASCE. Closing this window will shut down the server suddenly and it could corrupt the installation. To shut down WASCE, do the following. Go to Start Menu - > Programs Click on IBM WebSphere - > Application Server Community Edition Click on Stop the server. A new window will come, asking your username and password. Give the username as system and password as manager. Now, the earlier window, which opened during the start of server, will also close. Now, your WASCE server has been shut down safely. How WASCE works? To understand how WASCE works, you should first understand some basic concepts regarding network connections. A computer can connect with any other device (or with any other computer) through an interface called port. For example USB port, COM port, etc. These ports are of two types namely, hardware ports and software ports. The hardware ports are those, which physically exist. That is, you can see them with your eyes. (Eg. USB port). The software ports are imaginary ports that behave like hardware ports but do not physically exist. These are just some programs, which do the job of a port. This is just like WASCE doing the job of a very big computer, but, being inside a computer as a software. The WASCE uses these software ports for its functioning. The software ports are numbered from 0 to 65535. Just like your computer listening to your USB port, the WASCE listens to some ports. (You can get a list of ports listened in the figure shown above. It is displayed when the server is started.) WASCE listens to the port number 8080 (and some other ports also) in your local system for incoming requests. That is, if you want to view any web application stored in the WASCE, you have to request it through the port number 8080. In this context, host is the other name for server. (But, it may not be so in other contexts or other types of networks.) So, if you want to contact yahoo, you call http://www.yahoo.com/. Likewise, if you want to contact WASCE, (of course, after it is started), you have to type http://localhost:8080/ in your browser and click Go. The name localhost is given because the WASCE is installed in your local system and not on a remote computer.

G e a r U p T o T G M C - P a r t I | 16

The web browser will imagine that it is contacting a server somewhere far from it and send a request to it through the port number 8080. On the other side, the server will imagine the browser to be a remote client and serve the request by sending the appropriate file as output through the port number 8080. Thus, we can see that the entire process is simulated, that is, tested in same conditions, perfectly. Managing the WASCE There is a place called Administrative Console to manage the WASCE. In this, you can host new websites, delete existing websites, connect to the database server, etc. Now, let us see how to go to the administrative Console. Start the server Go the Start - > Programs Click on IBM WebSphere - > Application Server Community Edition Click on Administrative Console. It will open your default Web browser (Internet Explorer or Mozilla Firefox) with a web page in it. This is the login screen of the Administrative Console. Give the username as system and password as manager. (Do you remember that this step was performed somewhere earlier????) You will get a screen in which you have many administrative options for your server management. Now that you know how to enter administrative console, press logout and stop the server.

Note For Windows Vista Users: Note that you have to run the Administrative Console as Administrator.

G e a r U p T o T G M C - P a r t I | 17 A Few Exercises 1. Observe the WASCE startup window, see the terms used and get an idea about what they are all about from the Internet. 2. Observe and view all the options available in WASCE Administrative Console, but dont change anything unless you know what you are doing. 3. Observe the address displayed in the browsers address bar, when you are going to Administrative console, and try to give reason for why the address is so.

G e a r U p T o T G M C - P a r t I | 18

Chapter IV - Introduction to Eclipse


Introduction Eclipse is one of the powerful Integrated Development Environments (IDEs) for Java editing. Some add-ons are available in the internet exclusively for Eclipse and they are called Eclipse Plugins. They are used to extend the functionality of Eclipse. What is Eclipse? Eclipse is an Integrated Development Environment (IDE) for Java Developers. We have dealt about the IDEs in the first chapter. This contains an inbuilt debugging feature, which underlines the errors in codes as they are typed. This software provides many features needed for web application developers. Installation of Eclipse Eclipse does not need any installation for its usage. You would probably have a zip file for eclipse, when you download from the site. Just extract this zip in whatever location you want and then you can start using the software. Sometimes, you will get an Error message during Eclipse start, saying No JRE found. In that case, you just copy the JRE folder of your JAVA 1.4.2 (or whatever Java you have installed) installation folder and place it in the eclipse folder. Try restarting Eclipse. It will run now. Note For Windows Vista Users: Note that you have to run the Eclipse as Administrator. Initial Steps Eclipse has a special feature called Perspective, which defines the items to be shown on the screen. The default perspective chosen is Java Perspective. We will be developing the web applications using JSP. So, we must first switch to the J2EE (or Java EE) perspective. To do this, follow these steps.

1. 2. 3. 4.

Click on the icon encircled in the above figure. Select the option Other. Select J2EE (in some Eclipse Versions Java EE) and click Ok. Now, your perspective will be changed to J2EE (or Java EE) perspective.

What if I dont see neither Dynamic Web Projects nor Java EE? Dont worry. The most probable cause is that your Eclipse does not have a

G e a r U p T o T G M C - P a r t I | 19 plugin for WASCE. Search for WASCE plugin for Eclipse in the internet and download the one for your version of WASCE. It will give you a zip file. To install your WASCE plugin, go to Help->Software Updates-> Find and Install. Then choose New Archived Site and point to your downloaded zip file. This will install the WASCE plugin for you. Then, you can continue working as stated in following steps. What is a project? In Eclipse, a project is a set of files to do a specific set of tasks. For example, the project can contain source codes, web pages, library files and also any other necessary files. Here, our web application will be a project. In TGMC, we will be doing a Dynamic Web Project. (I hope you can justify this name.) For creating a new Dynamic Web Project, follow these steps: 1. In the J2EE perspective, right click on the Dynamic Web Projects in the Project Explorer window. 2. Select New - > Dynamic Web Project.

3. In the dialog box, type the name of the project (like myapp, crimerep, etc.) 4. Select the Target Run Time as Apache Geronimo with correct Version Number. If you do not find your server there, then go to step 5. Else, skip to step number 9.

G e a r U p T o T G M C - P a r t I | 20

5. Click on the New button next to Target Run Time Text Box. And, choose the Apache Geronimo

G e a r U p T o T G M C - P a r t I | 21

6. Click next and then in the Installation Directory, point to the AppserverCommunityEdition folder of your WASCE installation directory. 7. Then, press Finish. 8. Now, you can see the Apache Geronimo in the list box for Target Environment. Choose it. 9. Click Next and Finish. 10. Now, you will see that a new project in the given name is created under Dynamic Web Projects. (in some Eclipse variations, it will be created under JAVA EE) Once the project is created, you can see that there are many files automatically created in it. Adding Content to Project We have to add our content to the Web Content folder of the project. Now let us write our first HTML content in this folder. And, it is to be noted that, the first (home) page of a website is usually named index.htm or index.html. So, now let us build the home page of our web site or, theoretically the web application. We will soon run our project (that is, our web application) in an application server (WASCE). Whenever, our site is requested by the browser, this server will search for the index.htm or index.html file and send it to the

G e a r U p T o T G M C - P a r t I | 22 client. I think you now realize how the home page gets displayed when you just type www.yahoo.com in the browser and not www.yahoo.com/index.htm. To create a new HTML file in the project, do the following. Click on the + button near the Dynamic Web Projects. Double Click on the project, which you have created. Right Click the Web Content folder and select New - > HTML. In the New HTML Page dialog box, enter the name as index.htm Press Finish.

G e a r U p T o T G M C - P a r t I | 23

You will see that a new HTML page has been created with some prewritten code. Now go to the <body> line and type some text, which you want to display in browser (as shown in the figure). Save the file. Now, you have added the home page of your web application in the project.

G e a r U p T o T G M C - P a r t I | 24

A Few Exercises 1. Get some tutorial on HTML and read it. (You know, you can finish entire HTML in half a day(!!!!), including practical testing). Dont take any complete references, as they will tell the same concepts but, consuming more time. 2. Try designing a 5-page web site for a school. Dont forget to keep all the html files in a single folder. Dont forget to name the homepage as index.htm.

G e a r U p T o T G M C - P a r t I | 25

Chapter V Installations in Linux


Why Linux? The Linux Operating System is greatly used in commercial server environments due to the inherent security it provides. A simple security feature is that the conventional exe files cannot run in Linux, which is the reason for it to be less attacked by viruses. Another notable feature of linux is user account policies. This sets limitations on what a user can and cannot do and adheres to it. Thus, not only because of these but also because of many other features, Linux is preferred to be a OS of the choice, in case of servers. Installation issues in Linux An issue in linux is that there are no setup.exe files associated with installations. But, similar to them, we have installation archives in the .deb or .rpm format to be installed in different Linux Distributions. If you want to install a software in a Debian based linux like Ubuntu, you have to use .deb files and in case of Red Hat Linux, you have to use .rpm files. If you are new to linux, the best linux for beginners is UBUNTU linux, which is user-friendly and light-weight. This uses .deb files as installation scripts. This chapter covers installation of TGMC tools in Ubuntu Linux. The installation in other distributions will be nearly same, but not necessarily same. Installing JAVA SDK Java SDK has to be installed before installing WASCE. So, choose the version of WASCE first and go to the IBM site to know its required JAVA SDK version. Then, download the JAVA SDK of that version for linux. If you are using the CD/DVD provided by IBM, then, you will have JAVA SDK 5.0 installer in .rpm format. But, we said that Ubuntu does not support .rpm installers. There is a work-around to this problem. There is a package called alien available for converting .rpm files to .deb files. So, download and install alien in your system and then, convert this rpm to deb. After you have a .deb version of the JAVA installer, just double click on it and Linux will automatically install the software for you. It may ask some requisites. But, they can be easily installed by the Synaptic Package Manager present in the Ubuntu distribution. This completes the installation of JAVA SDK. Installing WASCE Installing WASCE involves some command line work. Better copy the installation folder into the Desktop and then follow these steps. 1. Open the terminal. 2. It will look like

G e a r U p T o T G M C - P a r t I | 26 yourusername@yourcompname$_ 3. What is important here is $ symbol. It says that you have been logged in as the user yourusername into the computer yourcompname and you are not the super (root) user, who has all previleges. If you are a root user, you will have # instead of dollar. cd helps us to enter into a folder. For example, to enter desktop folder, just type cd Desktop. dir helps us to know the contents of the folder. sudo is a command which is used to execute a linux command as a super user. Now, in the bold letters are given the prompt given by the system and in the purple italics are given the system's response to a particular command and ordinary text symbolizes the commands entered by the user. Follow these steps to install WASCE, if you are having a CD ROM given by IBM or else, if you have a separate installation folder, navigate to it and type the last command.

4.

5. 6. 7. 8. 9.

amirtharajan@amirtharajan-desktop:/$ dir

bin

dev initrd

lost+found opt proc

root sys var sbin tmp vmlinuz

boot etc initrd.img media cdrom home lib mnt

Recycled srv usr

amirtharajan@amirtharajan-desktop:/$ cd cdrom amirtharajan@amirtharajan-desktop:/cdrom$ dir

CE_Linux Workshop\ Reference


amirtharajan@amirtharajan-desktop:/cdrom$ cd CE_Linux/ amirtharajan@amirtharajan-desktop:/cdrom/CE_Linux$ dir

DB2\ 9\ Express\ C_Linux Eclipse\ 3.3_Linux.gz JDK\ 1.5 WASCE\ 2.0_Linux


amirtharajan@amirtharajan-desktop:/cdrom/CE_Linux$ cd WASCE\ 2.0_Linux/ amirtharajan@amirtharajan-desktop:/cdrom/CE_Linux/WASCE 2.0_Linux$ dir

bin

license

schema

wasce_setup-2.0.0.2-unix.bin

CHANGES.txt media.inf setup.jar

G e a r U p T o T G M C - P a r t I | 27

graphics lib

README.htm var repository _version.properties

amirtharajan@amirtharajan-desktop:/cdrom/CE_Linux/WASCE 2.0_Linux$ sudo ./wasce_setup-2.0.0.2-unix.bin 9. Now, your WASCE installation wizard will start and you can continue similar to Windows Setup for WASCE. 10. After installing WASCE, if you want to start your server, cd to the /opt/IBM/WebSphere/AppServerCommunityEdition/bin folder 11. Then type sudo ./startup.sh 12. This will start the server in background and you can open your browser and test the administrative console at https://localhost:8443/console after some time. 13. To stop the server, cd to the same folder and type sudo ./shutdown.sh Installing Eclipse Installing Eclipse is the easiest thing you can do in Linux. Just download the .zip file (meant for Linux) and extract it, preferably in a folder eclipse in your desktop for easy access. Now, Click on the eclipse executable after opening that folder in File Manager. This should open Eclipse, similar to Windows environment. If you get No JRE Found error, you copy and paste the JRE folder of Java SDK you have installed in your system. Now, restart Eclipse. It should work correctly. Once Eclipse is installed, you can follow the same instructions as given in the Windows Eclipse section of this tutorial. Installing DB2 Express C (Our sincere thanks to the forums in the internet, which helped us to collect, edit with modifications for simplicity and present it to you. Special thanks to the article by Rohith Kumar Thagilipally at http://itsrohith.com/db2.aspx) Installing DB2 Express C proves to be a lengthy task when compared to other softwares. The steps to be followed are as follows: 1. Unzip the DB2 zip file to your Desktop. 2. It will create a folder called exp where your installation files exist. 3. Dont unzip it to some folder like db2 setup\exp because the space between db2 and setup here would cause troubles during installation. 4. Search in it for the folder which contains the db2setup file and cd into that folder. 5. Then, type sudo ./db2setup. 6. This will start the db2 installation wizard and will be similar to the one mentioned in Windows section.

G e a r U p T o T G M C - P a r t I | 28 7. Before installing you have to install libstdc++ and libaio from the Synaptic Package Manager.

8. This will ask for three users, whose usernames and passwords have to be Hereafter, whenever we say db2inst1, you must understand that as your db2instance owner user and dasusr1 as your db2 administation user.

noted. Most important are Administrator for DB2, Instance Owner for DB2. Let me call them as dasusr1 and db2inst1 respectively.Note:

9. If the setup window is completely Grey, without any widgets, then try to disable the visual effects under Ubuntu. System -> Appearance -> Visual Effects -> None. Change the default shell for the DB2 default accounts. The default command shell for the DB2 accounts is set as just a plain old /bin/sh. To get the handy features of the BASH shell, you'll want to change it for these three accounts. In the same root access command window, open the /etc/passwd file in your favorite text editor and change: db2inst1:x:1001:1001::/home/db2inst1:/bin/sh db2fenc1:x:1002:1002::/home/db2fenc1:/bin/sh dasusr1:x:1003:1003::/home/dasusr1:/bin/sh to db2inst1:x:1001:1001::/home/db2inst1:/bin/bash db2fenc1:x:1002:1002::/home/db2fenc1:/bin/bash dasusr1:x:1003:1003::/home/dasusr1:/bin/bash 10. As the regular user, press Alt+F2 and type gksudo nautilus . This will give you a file manager with root previleges. Now, navigate to /etc and open services file in the Text Editor. Find and add this line to the end of the file: db2c_db2inst1 50001/tcp # IBM DB2 instance - db2inst1 Then, as the DB2 instance owner(after running su db2inst1 command), (db2inst1 by default), run these commands: db2 update dbm cfg using SVCENAME db2c_db2inst1 db2set DB2COMM=tcpip db2stop db2start 11. Enable remote DB2 administration connections. To allow remote administration of your DB2 server, you'll need to set up the DB2 DAS connection port, as it is not configured by the Synaptic installation process.

G e a r U p T o T G M C - P a r t I | 29 As the regular user, again open the /etc/services file as mentioned in the previous step and add this line to the end of the file: ibm-db2 523/tcp # IBM DB2 DAS ibm-db2 523/udp # IBM DB2 DAS Then, as the DB2 DAS owner (dasusr1) (that is, after running the command su dasusr1), run these commands: db2admin stop db2admin start Now remote administrators can connect to the DAS server to administer databases on your Ubuntu system. 12. Go to db2profile which is present under the sqllib. To do this type su db2inst1 in the terminal and change the directory by typing cd /home/db2inst1/sqllib Now open db2profile in text editor. Copy the last three lines of the db2profile and paste it to the tail of the .profile file, which can be seen only by ls -a command, since it is a hidden file. In the copied words you would find -f ${INSTHOME?}. Delete it and instead type /home/db2inst1. 13. To launch the control center, go to the terminal as ordinary user and type sudo xhost + 14. 15. 16. 17. This will make the current display to be available to all the users. Now, give su db2inst1 to login as instance owner. Now, type db2cc. This should open Control Center. From here, you can proceed with the same steps as Windows installation.

18. And, for each time you restart your computer, you should start the db2 instances by giving the following commands in the terminal. su db2inst1 db2start 20. To start the db2 administration service, in order to create, edit databases and tables, you have to type the following commands su dasusr1 db2admin start

G e a r U p T o T G M C - P a r t I | 30 21. To stop the db2 instances, again give the commands su db2inst1 db2stop 22. To stop the db2 administration service, give the commands su dasusr1 db2admin stop Conclusion Now that you have installed your Linux Version Softwares for TGMC and know all the differences of operating them in Linux and Windows, we believe that you can go ahead with your project development, with the same ease as in Windows. A Few Exercises 1. Try to know as many linux shell commands as you can. This can help you in one or other part of your project development. 2. Try to write a shell script to start your WASCE and DB2 services in a single click. You can save time in starting these services. 3. Also, on the contrary, write a shell script to stop the services with a single click.

G e a r U p T o T G M C - P a r t I | 31 Our Apologies to Tough Technocrats Most of the technical people might not very well appreciate this tutorial as it often describes some things in a non-standard or non-ideal way. But, as it is meant for beginners and non computer stream students, we cant expect them to understand the concepts like: there is an object called DataSource in a package called sql which is in turn a sub package of a package called java or the first row in a result set would contain metadata required for the processing of the returned result set. In another view point, we could see people running away from these ventures, when presented with such kind of hi-fi data. But, at a later point of time, if we feed these technical data as an add-on to what is already known, they are able to grasp it. It is noted that this is in contradiction to the pedagogical approach. We believe that it is enough to understand what each software does, in order to successfully complete a TGMC venture. So, please bear with our non-standard explanations and examples. These are aimed at better understanding of some working concepts by beginners and not aimed at misguiding the students.

G e a r U p T o T G M C - P a r t I | 32 Acknowledgements We would like to acknowledge the following people/organizations for their direct or indirect help to us in preparing this tutorial series. Mr. R. Amirtharajan, Senior Lecturer, Department of ECE, SASTRA Our primary thanks goes to him. It is he who motivated us to do something for others apart from learning something for ourselves. He provided his desktop system for us to build our TGMC solution and for preparing this tutorial series. His feedbacks on our solution and this tutorial have always been useful. Without his Computer, we dont believe that we could have done this tutorial as well as our solution for TGMC. We feel that it is our duty to thank him. Mr. Rajaraman Srinivasan, Former Senior Lecturer, Department of IT, SASTRA He was the one who taught us the basic concept of web applications, client-server architecture, databases, etc. This tutorial, in fact, includes most of the ideas conveyed by him to us. His seminar for a single day on all these IBM tools for all students of SASTRA made us to do the TGMC for the last year. This year, as we dont have him in teaching profession, we realize that it is our duty to carry on his job. This tutorial is a brain-child of that realization. Our special thanks to him. IBM Academic Initiative Obviously, we have to thank the IBM Academic Initiative team for providing us a platform to know about these fascinating technologies. Without this, our regular course work would have not kept us well informed about the web. This has been our basement for our interest and knowledge-acquisition in hacking, web security, web designing, etc. Thanks to IBM for making us the fans of web technology and fans of Linux. We would like to extend our support, if possible, even in the smallest means for this Academic Initiative and we hope that this tutorial is an example of our commitment to Academic Initiative of IBM. And at last, our student friends, for their constant feedbacks, suggestions and doubts from which we learnt much more than what we already knew. Thanks and our best wishes to our friends for their future.

G e a r U p T o T G M C - P a r t I | 33 A Prelude To Gear Up to TGMC Part II Next part of this tutorial will explain you about testing your site, connection between database server and your web application and some more concepts. In the part two, we will introduce JSP to you and at the end of this part two, you will be able to do most of the jobs required for TGMC on your own. What we want you to do is to think of some useful database design for your project that would satisfy functional requirements of your project as given in the TGMC web site. Then, decide the users of the system and prepare a list of jobs of each user. This will help you in going through the second part. Any comments/feedbacks can please be sent to gearuptotgmc@gmail.com for correction in the future. We will be pleased to correct the mentioned errors. You can also mail us for clarifications. We will provide you with explanations, if we can and if we know. All the Best!!!!! -The Illuminati (G. Vivek, S. Kamal Raj, Srinivas Mitpellywar), SASTRA University.

You might also like