Wednesday, June 27, 2007

Javascript in Address bar

Recently i was asked to design a system which performs some operation.The technology used was jsp.The operation is , i have two jsp pages , first.jsp and second.jsp. 'first.jsp' has a form that takes input from the user.On submitting the form , it goes to 'second.jsp' where some database operation is carried on based on certain conditions.For example, partA of the database operation is carried on if the condition succeeds and partB is carried on if the condition fails.But the condition parameter is neither hardcoded nor supplied by the user through the GUI. The user need to add the condition parameter to the url in the address bar.

for example like ,

"http://www.mydomain.com/second.jsp?conditionparameter=parametervalue"

Since the url ("http://www.mydomain.com/second.jsp") has been already specified in the forms action attribute of the 'first.jsp',as well as the option of getting the condition parameter from the user through popup or alert or anykind of GUI is restricted , and passing the conditionparameter as the query string is the only way allowed i tried fetching the URL from the address bar through some javascript and jsp methods.

In the case of javascript , i tried using document.location and windows.location.href, windows.location.search etc. In the case of jsp , i tried httpservletrequest , response objects methods.But in both cases , i could not get the condition parameter that i specify in the address bar.

After a long head ache, i found the strength of java script. yes , i just typed the javascript in the address bar while being in the 'first.jsp' page.

This is the following code , i just typed in the address bar after cleaning the url already present there.

javascript:document.formname.action="http://www.mydomain.com/second.jsp?conditionparameter=parametervalue"
Thats it. Finally the form details along with the condition parameter has been caught in the 'second.jsp' and the task was completed successfully.

Thursday, June 14, 2007

IN THE LINE OF FIRE... !!!

Vivek Pradhan was not a happy man. Even the plush comfort of the air-conditioned compartment of the Shatabdi express could not cool his frayed nerves. He was the Project Manager and still not entitled to air travel. It was not the prestige he sought, he had tried to reason with the admin person, it was the savings in time. As PM, he had so many things to do. He opened his case and took out the laptop, determined to put the time to some good use.

"Are you from the software industry sir," the man beside him was staring appreciatively at the laptop.

Vivek glanced briefly and mumbled in affirmation, handling the laptop now with exaggerated care and importance as if it were an expensive car.

"You people have brought so much advancement to the country sir. Today everything is getting computerized."

"Thanks," smiled Vivek, turning around to give the man a look.

He always found it difficult to resist appreciation. The man was young and stocky like a sportsman. He looked simple and strangely out of place in that little lap of luxury like a small town boy in a prep school. He probably was a railway sportsman making the most of his free traveling pass.

"You people always amaze me," the man continued, "You sit in an office and write something on a computer and it does so many big things outside."

Vivek smiled deprecatingly. Naivety demanded reasoning not anger. "It is not as simple as that my friend. It is not just a question of writing a few lines. There is a lot of process that goes behind it." For a moment, he was tempted to explain the entire Software Development Lifecycle but restrained himself to a single statement. "It is complex, very complex."

"It has to be. No wonder you people are so highly paid," came the reply.

This was not turning out as Vivek had thought. A hint of belligerence came into his so far affable, persuasive tone.

"Everyone just sees the money. No one sees the amount of hard work we have to put in.Indians have such a narrow concept of hard work. Just because we sit in an air-conditioned office does not mean our brows do not sweat. You exercise the muscle; we exercise the mind and believe me that is no less taxing."

He had the man where he wanted him and it was time to drive home the point.
"Let me give you an example. Take this train. The entire railway reservation system is computerized. You can book a train ticket between any two stations from any of the hundreds of computerized booking centres across the country. Thousands of transactions accessing a single database, at a time concurrency; data integrity, locking, data security. Do you understandthe complexity in designing and coding such a system?"

The man was stuck with amazement, like a child at a planetarium. This was something big and beyond his imagination. "You design and code such things."

"I used to," Vivek paused for effect, "But now I am the Project Manager,"

"Oh!" sighed the man, as if the storm had passed over, "so your life is easy now."

It was like being told the fire was better than the frying pan. The man had to be given a feel of the heat.

"Oh come on, does life ever get easy as you go up the ladder. Responsibility only brings more work. Design and coding! That is the easier part. Now I do not do it, but I am responsible for it and believe me, that is far more stressful. My job is to get the work done in time and with the highest quality. To tell you about the pressures, there is the customerat one end always changing his requirements, the user wanting something else and your boss always expecting you to have finished it yesterday."

Vivek paused in his diatribe, his belligerence fading with self-realisation. What he had said, was not merely the outburst of a wronged man, it was the truth. And one need not get angry while defending the truth. "My friend," he concluded triumphantly, "you don't know what it is to be in the line of fire."

The man sat back in his chair, his eyes closed as if in realization. When he spoke after sometime, it was with a calm certainty that surprised Vivek.

"I know sir, I know what it is to be in the line of fire," He was staring blankly as if no passenger, no train existed, just a vast expanse of time.

"There were 30 of us when we were ordered to capture Point 4875 in the cover of the night. The enemy was firing from the top. There was no knowing where the next bullet was going to come from and for whom. In the morning when we finally hoisted the tricolour at the top only 4 of us were alive."

"You are a..."

"I am Subedar Sushant from the 13 J&K Rifles on duty at Peak 4875 in Kargil. They tell me I have completed my term and can opt for a land assignment. But tell me sir, can one give up duty just because it makes life easier. On the dawn of that capture, one of my colleagues lay injured in the snow, open to enemy fire while we were hiding behind a bunker. It was my job to go and fetch that soldier to safety.""But my captain refused me permission and went ahead himself. He said that the first pledge he had taken as a Gentleman Cadet was to put the safety and welfare of the nation foremost followed by the safety and welfare of the men he commanded.""His own personal safety came last, always and every time. He was killed as he shielded that soldier into the bunker. Every morning now, as I stand guard I can see him taking all those bullets, which were actually meant for me. I know sir, I know what it is to be in the line of fire."

Vivek looked at him in disbelief not sure of his reply. Abruptly he switched off the laptop. It seemed trivial, even insulting to edit a word document in the presence of a man for whom valour and duty was a daily part of life; a valour and sense of duty which he had so far attributed only to epical heroes.

The train slowed down as it pulled into the station and Subedar Sushant picked up his bags to alight.

"It was nice meeting you sir."

Vivek fumbled with the handshake. This hand had climbed mountains, pressed the trigger, and hoisted the tricolour. Suddenly as if by impulse,he stood at attention and his right hand went up in an impromptu salute. It was the least he felt he could do for the country.

PS: The incident he narrates during the capture of Peak 4875 is a true-life incident during the Kargil war. Capt. Batra sacrificed his life while trying to save one of the men he commanded, as victory was within sight. For this and his various other acts of bravery he was awarded the Param Vir Chakra the nation's highest military award.

Moral : Live humbly, there are great people around us, let us learn!!!!

Thursday, June 7, 2007

Never GUESS

In the days when you couldn't count on a public toilet facility, an English woman was planning a trip to India. She was registered to stay in a small guest house owned by the local schoolmaster. She was concerned as to whether the guest house contained a WC. In England, as you know, a bathroom is commonly called a WC which stands for "Water Closet". She wrote to the schoolmaster inquiring of the facilities about the WC.

The school master, not fluent in English, asked the local priest if he knew the meaning of WC. Together they pondered possible meanings of the letters and concluded that the lady wanted to know if there was a " Wayside Chapel " (Place where Celebrations are done especially like a beautiful garden) near the house . . . a bathroom never entered their minds.

So the schoolmaster wrote the following reply:

Dear Madam,

I take great pleasure in informing you that the WC is located 9 miles from the house. It is located in the middle of a grove of pine trees, surrounded by lovely grounds. It is capable of holding 229 people and is open on Sundays and Thursdays. As there are many people expected in the summer months, I suggest you arrive early. There is, however, plenty of standing room. This is an unfortunate situation especially if you are in the habit of going regularly. It may be of some interest to you that my daughter was married in the WC as it was there that she met her husband. It was a wonderful event. There were 10 people in every seat. It was wonderful to see the expressions on their faces. We can take photos in different angle. My wife, sadly, has been ill and unable to go recently. It has been almost a year since she went last, which pains her greatly. You will be pleased to know that many people bring their lunch and make a day of it. Others prefer to wait till the last minute and arrive just in time. I would recommend Your Ladyship plan to go on a Thursday as there is an organ accompaniment. The acoustics are excellent and even the most delicate sounds can be heard everywhere. The newest addition is a bell which rings every time a person enters. We are holding a bazaar to provide plush seats for all since many feel it is long needed. I look forward to escorting you there myself and seating you in a place where you can be seen by all.

RAJINI'S POPULARITY

There is a popular story saying that wherever you go, you will find atleast a Rajinikanth fan

Here is an interesting new story...!

Rajinikanth was bragging to Jayalalitha one day, "You know, I know everyone there is to know. Just name someone, anyone, and I know them."Tired of his boasting, Jayalalitha called his bluff, "OK, Rajini how about Tom Cruise?" "Sure, yes, Tom and I are old friends, and I can prove it" Rajini said.So Rajini and Jayalalitha fly out to Hollywood and knock on Tom Cruise's door, and sure enough, Tom Cruise shouts "Thalaiva! Great to see you! You and your friend come right in and join me for lunch!". Although impressed, Jayalalitha is still skeptical.After they leave Cruise's house, she tells Rajini that she thinks Rajini knowing Cruise was just lucky. "No, no, just name anyone else" Rajini says.

"President Bush", Jayalalitha quickly retorts. "Yes", Rajini says, "I know him, let's fly out to Washington". And off they go. At the White House, Bush spots Rajini on the tour and motions him, saying, "Rajini, what a surprise, I was just on my way to a meeting, but you and your friend come on in and let's have a cup of coffee first and catch up". Well, Jayalalitha is very shaken by now, but still not totally convinced.After they leave the White House grounds, she expresses his doubts to Rajini who again implores her to name anyone else.

"The Pope", Jayalalitha replies. "Sure!" says Rajini, "My folks are from Poland and I've known the Pope a long time". So off they fly to Rome.Rajini and Jayalalitha are assembled with the masses in Vatican Square when Rajini says, "This will never work. I can't catch the Pope's eye among all these people. Tell you what, I know all the guards so let me just go upstairs and I'll come out on the balcony with the Pope." And he disappears into the crowd headed toward the Vatican. Sure enough, half an hour later Rajini emerges with the Pope on the balcony.

But by the time Rajini returns, he finds that Jayalalitha had a Heart Attack and is surrounded by paramedics.Working his way to Jayalalitha's side, Rajini asks her, "What happened?"

Jayalalitha looks up and says, "I was doing fine until you and the Pope came out on the balcony and the man next to me said, Who's that on the balcony with Rajini?"

Tuesday, June 5, 2007

Microsoft Sql Server2000

To connect to a remote database server from local.

In Ms sql server , clik on enterprise manager. In the console you will have the databases listed in the tree structure.In that tree Right-Click on the "SQL Server Group" item.In the poup menu click "New sql Server registration".It will open a wizard.In the Welcome wizard press Next. Then another wizard appears asking to select a server from the available server.If you dont see one , just type the ip address and add it.On clicking Next, You will need to set authentication mode in another wizard, then you need to selectsql server group.Atlast Finish.After the process succeeds, you can see the database added to your existing database.To be more precise, it is not only the database, but also one among the "SQL Server Group". So any changes made to this database , will be affected in the server.

If you want to import the database for local testing alone, then follow the below procedure.

First create a database with the name of the database that you are going to import.Then Right-click on the local "SQL Server Group" and click on "All Tasks".In that select "Import Data". Then you will be going through a set of wizards,that asks for input.In the "Import/Export" wizard click Next.Then in "Data Source" wizard, specify the server address, then choose appropriate authentication and then choose the database to be imported.Then in the "Destination" wizard , choose the "Local" system as server, give the appropriate authentication and then choose the database you created in the local system.Then in the "table copy or query" wizard , choose "copy objects and data between sql server databases" option.Then click on Next in the following wizard. A copy of the database will be copied from the server to the local one.

Change Your Vision

There was a millionaire who was bothered by severe eye pain. He consulted so many physicians and was getting his treatment done. He did not stop consulting galaxy of medical experts; he consumed heavy loads of drugs and underwent hundreds of injections.

But the ache persisted with great vigor than before. At last a monk who has supposed to be an expert in treating such patients was called for by the millionaire. The monk understood his problem and said that for sometime he should concentrate only on green colors and not to fall his eyes on any other colors. The millionaire got together a group of painters and purchased barrels of green color and directed that every object his eye was likely to fall to be painted in green color just as the monk had directed.

When the monk came to visit him after few days, the millionaire's servants ran with buckets of green paints and poured on him since he was in red dress, lest their master not see any other color and his eye ache would come back.

Hearing this monk laughed said "If only you had purchased a pair of green spectacles, worth just a few rupees, you could have saved these walls and trees and pots and all other articles and also could have saved a large share of his fortune. You cannot paint the world green." Let us change our vision and the world will appear accordingly. It is foolish to shape the world, let us shape ourselves first.

Lets change our vision..!! Think simple, Live simple.."