Monday, October 31, 2011

Hello world – Struts 2

It took awe fully a lot of time for me to do this simple stuff as I was not too comfortable with JSP, tomcat and eclipse Indigo. Though I followed most of the hello world tutorials available out there, I always ended up with some errors or the other.

Some of the important lessons that I have learnt with this sufferings are,

1.       Java frameworks are not reverse compatible. I hate that.

2.       Code developed with say jdk1.5 environment probably won't work with jdk1.6 and vice versa

3.       Only use prescribed files by all means and do not try including any new stuffs before u know what it is as far as the java technology is concerned.

Since I come from a technology which is RAD and reverse compatibility is never an issue, IT IS REALLY HARD FOR ME TO DIGEST ABOUT THIS IN JAVA WORLD L   

Any ways I am starting to getting used to this and here is my hello world to Struts 2.


1.       Tomcat server version 6.0 or 6.0.33 needs to be installed. No other versions. Probably other versions in 6 might support but I am not sure

2.       JDK 1.5 is required. Don't switch to higher version or u might end up having a tough time finding what the problem is. Well if you are a java guy, you would know it better than me.

Following is the folder structure that you need to have

The lib directory should contain all of the following files



All the files that you find in the above screen shot are frame work files that comes with Struts 2 package version 2.1.2 I guess. You can google down with the names of the files to find the appropriate sub version of struts 2. Believe me it did not work with version 2.1.6.

Please don't blame me if you can do it better. I am very new to this technology J

Key in the following code to HelloWorldAction class

You web.xml file should have the following code

The popup text that you find in the above image shows the filter class that helps your web.xml file understand the presence of struts.xml file.

Following is how my struts.xml file looks like.


The action name "helloworldAction" can be any name of your choice.

The class name "web.HelloworldAction"  tells the compiler to look into this specific class to execute the specific method

The method name "helloWorld" asks the compiler to look for this particular method and perform the necessary action inside the provided class in the class name parameter

Finally the index.jsp is as follows

Now save your work, move your project to the tomcat server, by doing the following

After doing this click finish.


Now restart your tomcat server or simply start it if its not already running.

Now key in the following url in your browser. I did this one with the browser provided by eclipse it self



Note the differences in the above mentioned images,

When you provide the url for helloworldAction class directly you can see the print statements provided inside the helloWorld method in the console. Possibly you can use this one to your advantage

Hope this helps J

Saturday, October 29, 2011

Configuring ODBC Connection for Oracle in Windows 7

1. In order to configure a ODBC connection for Oracle in windows 7 follow the following steps

2. Goto Start->Control Panel->Administrative Tools->Data Sources (ODBC)

3. The following screen titled “ODBC Data Source Administrator” will be opened up

4. Now choose the System DSN tab and click on add.

5. This will open up a new window titled “Create New Data Source”

6. Scroll down to “Microsoft ODBC for Oracle” and click Finish

7. This will result in the following window. Provide the credentials as required and click ok

About TNSNames.ora

This is in continuation to my previous article where I mentioned about TNSNames.ora.
Again this is my understanding and am a beginner1. The Location where you would find tnsnames.ora file inside a oracle client directory is typically inside the NETWORK\ADMIN folder

2. In My case it is inside d:\oracle\product\11.2.0\client_1\NETWORK\ADMIN

3. This is one file that you should know to create if you want to create connections in SQL Developer client to databases in sever.

4. A sample copy of tnsnames.ora file will be available in the SAMPLE Directory. When in doubt copy paste it and make necessary modification to it

5. The various elements that should be understood in this file are as follows

Hello World Oracle SQL Developer

Well by Oracle SQL Developer, I mean a developer tool and not a programmer/developer. :)

Following are purely my own understanding as a beginner to work with Oracle SQL Developer.
  1. When you install a oracle server 2008, you will automatically obtain a Oracle SQL Developer client with it.
  2. You cannot create a new database with Oracle SQL Developer client. In order to do that you would require an Admin Client for the same.
  3. So in order to work with databases you have to create a connection to the oracle database residing in a server from the developer client.Following section illustrates the same
  4. A typical Oracle SQL Developer 1.5.5 looks like the following

5. Right Click on Connections and click New Connection

    6. This will result in the following window

      7. First choose the Network Alias. The list of Network Aliases that you see here comes from tnsnames.ora. This is one Important file that would be found in Network/Admin folder.Since this is very important I have documented my understanding on the same in a separately. So refer to the same after go through this one.

      8. The network alias that I have chosen here corresponds to a particular database that has been configured in tnsname.ora
      9. Now key in a connection name of your choice and provide a valid username and password. I know it sounds irritating. Yes you got to have them before trying this one. Speak to some one who can help you on this if you don’t know how to get it. Also as always you can google it.
      10. Now click on test. If the info "Status: Success" appears on the left side of the window then you are ready to go. If not, hmmm… I am not sure. God bless you. Seek help some where.
      11. Now click on Connect. This will result in a new connection as shown in the following image

        12. Now there are two ways by which I can open up the sql console for this connection. They are as follows
          i. First way –using the quick launch icon

          ii. Using the tools menu
          13. Thus you can arrive at the following sql console

            14. Here is my hello word to SQL

            Run Apache-Tomcat with in Eclipse Indigo

            I never knew I can do so much with eclipse with ease. I have made this post earlier for a different version of eclipse named Yoxos. It was quite hard in that and with Indigo its too easy.

            Just follow the following steps.

            1. Download Apache-Tomcat to your preferred directory.

            2. Open up eclipse Helios

            3. Choose Window Preferences as illustrated in the following image

            4. In the preferences window that opens up , choose ServerRuntime Environments and click Add buttonin the right hand side

            5. Choose the version of your tomcat server and click next. This list is auto populated and so don’t worry on how to create it.

            6. On the next window that popups up, browse and add the folder path of your tomcat server and click finish. You also have a option to Download and Install, You can try that if you prefer and click finish.

            7. Now your tomcat server is configured in eclipse. This is pretty simple when compared to the previous versions.

            8. Now In order to start the server, you must do the following. Right click in your navigator pane, choose NewOther

            9. Choose server --> server

            10. Choose the credentials mentioned in the following image and click finish

            11. I think you can understand the remaining from the next screen shot

            Tuesday, October 18, 2011

            Installing a IIS Server in Windows 2007

            This helps you work with inbuilt server in windows that helps you work with asp pages etc
            1. Open the control panel and click on the “Unistall a program” option. Now choose “Turn Windows Feature on or off” as illustrated by the following image

            2. Now from the list of windows services that popup select “Internet Information Services” and don’t bother about the sub services that are selected or deselected for now. Just accept the defaults

            3. This will start an installer and a popup with a progress bar will appear when you click ok. Once that is complete you are ready to go with the IIS

            4. Now you need to know how to check whether the IIS server is running or not. That’s correct. I am speak about that in the forth coming steps

            5. Open up the device manager in windows 2007

            6. Now Select “Internet Information Services(IIS) Manager” under the “Services and Applications” as highlighted in the Image

            7. Now take a close look at the screen that appears on the right side. I believe you will understand the importance of the highlighted section. If not may be u are comparably as dumb as me . U can start, stop and restart your IIS server using those options ha ha lol

            8. Select Default Web Site and take a close look at the options in the right hand side.You would have already noticed that you see a new set of actions being displayed there. Don’t ask me how they got there…cos I am not ready for those questions yet 

            9. Now select bindings and select edit in the popup box. Now you will be able to specify the port for your server to operate on in your machine. I prefer to change this one cos I test run a lot of server on my machine. For example I have Lotus Domino Server, Apache Tomcat, IIS etc.. So I prefer to have a custom port for every thing to avoid conflicts. It is not mandatory for you to change this. But its better to leave port 80 undisturbed atleast for training purposes. Also be warned not to use any ports that are already in use. Google about this stuff and you will get a lot of really good advice on choosing a proper port for your machine. If you are in a corporate world, SYS/Network admins are the first people to speak about this to. Just to ensure that we don’t mess it up for them 

            10. Now open up your local iis server in the browser. In my case the url is http://localhost:8081 and the page looks like

            11. To add your custom pages you got to navigate to the following page and add your file

            12. Now add a helloworld.html file to this folder and put the following html tags into it.

            Hello World!

            And preview the same in the browser. Thus I got my Hello world on the IIS server

            Well… hope this helps 

            Saturday, October 15, 2011

            Bugs: Ajax Caching issue in IE

            Hats of to IE. It tests my mettle. Not a day goes by with out finding issues with IE one way or the other when I attempt to get some thing work the way I expect them to.
            The good part is it helps me learn a lot from technology point of view as it is so different from other browsers and even simple things require a lot of work in IE.

            Once an ajax request is created from the IE browser, it caches the same if it is a get request and this is absolutely absurd. I try getting a value through an Ajax request that varies frequently and because of this cache, I dont get the most recently updated value.

            I have to restart the browser to get the recent value.

            But with Post request, thank god, they are out of IE's caching issues. My saviour of the day is- AJAX POST REQUEST. This forces a fresh new request be triggered every time and the parameter that I provide are safer too.