Wednesday, October 13, 2010

01 TGMC : The Starting Problem

Starting with this, there would be a series of posts that would try to help students who are looking to participate in IBM's The Great Mind Challenge. One of the biggest software development contest at present.

For those who have no prior knowledge of how to build a software application, your journey of Enterprise application development starts here and we hope to make it as easy and comfortable as possible. :)

Assuming the readers have some basic knowledge of core java and HTML, we are now ready to build our first simple "HelloWorld" application.

Software Required:

1. IDE - Eclipse
2. Application Server - IBM WASCE / Apache Tomcat 6.0
3. RDBMS - IBM DB2
3.Text Editor - NotePad++ (a good text editor that could come handy)
4. jdk 1.5 or above

Step 1:

Install the software mentioned above, which can be obtained online or from the DVD ( excluding NotePad++ which needs to be downloaded) provided by IBM to your college. We would not need IBM DB2 for this exercise, we shall see how to work with DB2 in the coming posts.

Eclipse does not require a installation, all you need to do, is extract the compressed file to an appropriate location and choose a "workspace" where you would be placing all the projects.

Step 2:

So, we are all set to get started with Eclipse, to build our first Hello World web application.

Now, to create a new project, Click on File -> New -> Web -> Dynamic Web Project


On choosing which, you will be asked for a project name, give a name of your choice say, "HelloWorld".

The next thing we are supposed to do is set the "Target Runtime" , i.e, on which application server would we be running the web application. In this case we need to set it to IBM WASCE.
Clicking on "new" would give us the following dialog box.

Choose IBM WASCE v2.0 and click next, where it asks for the Server installation directory. Point it to the location where you installed the Wasce app server on your machine and say "Finish" to set up IBM Wasce app server on Eclipse.


Step 3:

Once we are done with setting up the runtime server, now we need to create the first jsp, for that, right click on your project in the Project Explorer, and create new JSP with a name say, "welcome.jsp" and assuming you have some basic knowledge of HTML, we just add a simple header tag, which says "Hello World!!".

Then before we can run this application, we need to do a small check with the web.xml file that, u can find at ../WEB-INF/web.xml

By default in the web.xml file you can find that the default welcome page (that is the page which is displayed once the application is started) is set to "index.html/index.jsp" since, we created a jsp with the name "welcome.jsp" we need to edit the web.xml file, and set "welcome.jsp" in the welcome-page list as shown in the figure below.

Once you have done this, we are ready to run the application.

Step 4:

Now to run the application, right click on the project in the project explorer, and choose Run-> Run on Server option.


On clicking which, the server startup is initialized, be patient, the server takes a little time to start up, but once its done you can see the following message on the console window.


Immediately after the server startup is completed, an Internal Web Browser is started, and the application's welcome page is displayed. (You can set the default web browser at your default web browser, eg. IE or firefox). To do that click on the Window-> Web Browser from the menu bar and set the web browser of your choice.


As you can see, the welcome page displaying "Hello World" is obtained on the internal web browser.

So, Congratulations you have just successfully created and deployed your first web application!! :)

Our next post would be on Database Connectivity, which is coming soon.

2 comments:

  1. sorry ...
    can i deploy in wasce as that in tomcat ie copying the folder architecture into webapps folder ???

    ReplyDelete
  2. Puneeth,

    Its better you run it on eclipse, instead of copying the folder on to the WASCE app server folder.. Alternatively you can export a .war file of your web application from Eclipse and deploy it using the WASCE admin console.

    ReplyDelete