He was remembered as a leader and a thinker, a man whose wit and courage helped sustain him and hundreds of other U.S. prisoners of war through years of isolation and torture in North Vietnamese prison camps.

James B. Stockdale, the retired vice admiral and Medal of Honor winner, was buried yesterday at the United States Naval Academy in Annapolis with all the pageantry befitting one of the modern Navy's most revered figures.

A mourning cannon boomed 15 times, followed by a 21-gun salute before his coffin was lowered into a hillside grave overlooking the waters of the Severn River that he sailed as a midshipman 60 years ago. Under a cloudless sky, a bugler played taps and four Navy F-18s thundered overhead in a tight diamond formation, the final aircraft curling off to symbolize a fallen aviator.

The burial followed a chapel service attended by more than 500 people, including seven Medal of Honor winners, distinguished academy graduates Ross Perot and Sen. John McCain (R-Ariz.) and former astronaut and senator John Glenn (D-Ohio), who was a test pilot with Stockdale at Patuxent River Naval Air Station before the war. They sat alongside less-known figures, some still limping from wounds suffered at the infamous "Hanoi Hilton" prison, where Stockdale spent 71/2 years after being shot down in 1965.

"His consistent philosophy was, 'Follow me,' and he meant it," retired Adm. William J. Crowe, former chairman of the Joint Chiefs of Staff and Stockdale's longtime friend, told the mourners. "And that carried over into his time in the prison camps."

Stockdale, 81, died July 5 at his home in Coronado, Calif. The Navy said he had Alzheimer's disease.

Stockdale is widely remembered as Perot's seemingly bewildered 1992 vice presidential running mate, who opened a televised debate by asking: "Who am I? Why am I here?" Intended as philosophical, the questions apparently missed their mark. "Saturday Night Live" portrayed him as a caricature.

Yesterday, there was no mention of the caricature, only the hero, husband and father.

As his widow, Sybil, looked on from a wheelchair, Stockdale's four sons paid tribute to him, recalling him as a doting father who relished his time with them after being away so long.

Taylor Stockdale, who was 21/2 when his father was shot down and didn't see him again until he was 10, drew chuckles from the audience when he recalled asking his father on his return home, to take him camping.

"Can you think of anything worse than a camping trip for a man who just got released from a Vietnamese prison?" Taylor Stockdale, of Albuquerque, said.

His father took him, and for the first time the boy got to know his father away from the publicity surrounding his release. "In so many ways, that trip was a pivotal moment in my life," Taylor Stockdale said.

James Bond Stockdale was born in Abingdon, Ill., the son of a factory worker who enlisted as a sailor in World War I and was determined to see his only child attend the Naval Academy. He graduated in 1946 and was later sent by the Navy to graduate school at Stanford University, where he became enamored with philosophy.

On Sept. 9, 1965, the 41-year-old Navy commander's A-4 fighter jet was hit by flak during his 201st mission over North Vietnam. Stockdale ejected and landed hard in a small coastal town, breaking a leg and dislocating a shoulder. Villagers pummeled him as he lay helpless.

He was taken to the Hoa Lo prison in Hanoi, which prisoners soon dubbed the Hanoi Hilton. As the senior ranking Navy officer in captivity, Stockdale knew he would be a target for torture and worried what he might divulge.

As 1965 closed, the torture began. The most brutal technique -- known as "the ropes" -- used hemp cord to cut off blood and oxygen and contort sockets nearly out of joint. There also were beatings and long periods in solitary confinement in squalid, windowless cells, often in leg irons. Stockdale spent more than four years in solitary. His leg was broken again during one interrogation, and he would never regain full use of it.

As the years passed, Stockdale was comforted by thoughts of his family and the ancient Stoics he had studied at Stanford. He later would say he found particular strength in Epictetus, a crippled former slave who told his students to "make the best use of what is in your power, and take the rest as it happens."

Stockdale used that strength to defy his captors. He led hunger strikes, passed secret messages to Naval Intelligence through coded letters to his wife -- what few got through -- including the names of prisoners mistakenly declared killed in action. And he devised rules to help fellow prisoners remain unified and resist becoming propaganda tools. Among the rules: Never bow to guards in public or go on camera or radio for them.

He transmitted the rules throughout the camp through a secret wall-tapping code the prisoners devised. Many prisoners later credited the rules with helping them retain their spirits after torture sessions.

"They were a very concrete set of guidelines, something we put our fingers around," Paul Galanti, 66, of Richmond, who spent seven years in Hanoi, said after the service.

Another former POW, retired Cmdr. George Coker, 62, who could not attend the burial but who stayed close to Stockdale after the war, said in a phone interview from his home in Virginia Beach: "The important thing was to bounce back, not to get on a downhill roll and become putty in their hands. That was the big thing about the rules, was the snapback."

Stockdale so adhered to the code that he beat his face bloody with a mahogany stool rather than allow himself to be used in a propaganda film. Later, after a savage day of beatings following the death of North Vietnamese President Ho Chi Minh, he slashed his wrists with broken glass, afraid of what he might give up in a promised second day of torture. Guards found him in a pool of blood and revived him, and the incident later was credited for convincing the North Vietnamese to reduce the use of torture.

Stockdale was released Feb. 12, 1973. He received the Medal of Honor in 1976 and later headed the Naval War College and The Citadel. He retired from active duty in 1979 and spent his later years lecturing and writing.

Those close to him said he never harbored ill feelings for his captors after his release. "He wasn't one of those guys who said we have to get back at those North Vietnamese," said Glenn, who remained close to Stockdale after their test pilot days. "He felt he did what he had to do and they did what they felt they had to do."

He added that Stockdale was "one of our greatest."

Stockdale stayed away from the political spotlight after the 1992 election, but eight years later came to fellow POW McCain's defense when questions arose about his stability for the job of president during the 2000 campaign, calling him "solid as a rock" in a New York Times commentary.

After yesterday's service, McCain returned the sentiment, recalling his time as a prisoner in Hanoi and the strength he drew from Stockdale.

"He inspired us to do things that we otherwise could never have done," McCain said. "He was our beacon and our strength -- and that's why we all loved him so much."

With his mother, Sybil Stockdale, watching, James B. Stockdale II places a rose on his father's coffin.James B. Stockdale helped fellow prisoners of war survive.