Answer by taking a quote from the following article:

James Bond Stockdale (December 23, 1923 - July 5, 2005) was a United States Navy vice admiral and aviator awarded the Medal of Honor in the Vietnam War, during which he was a prisoner of war for over seven years. Commander Stockdale was the senior naval officer held captive in Hanoi, North Vietnam. He had led aerial attacks from the carrier USS Ticonderoga (CVA-14) during the 1964 Gulf of Tonkin Incident. On his next deployment, while Commander of Carrier Air Wing Sixteen aboard the carrier USS Oriskany (CV-34), his A-4 Skyhawk jet was shot down in North Vietnam on September 9, 1965.

On June 5, 1946 he graduated with a Bachelor of Science degree from the Naval Academy with the Class of 1947 due to the reduced schedule still in effect from World War II. Academically he ranked 130th among 821 graduates in his class. His first assignment was assistant gunnery officer aboard the destroyer minesweeper USS Carmick (DD-493) from June to October 1946. He next served aboard the USS Thompson (DD-627) from October 1946 to February 1947, the USS Charles H. Roan (DD-853) from February 1947 to July 1948, and the USS Deming (PCS-1392) from July 1948 to June 1949. Stockdale was accepted for flight training in June 1949 and reported to Naval Air Station Pensacola in Florida. He was designated a Naval Aviator at Naval Air Station Corpus Christi in Texas, in September 1950. He was next assigned for additional training at Naval Air Station Norfolk in Virginia from October 1950 to January 1951. In January 1954, he was accepted into the United States Naval Test Pilot School at the Naval Air Station Patuxent River base in Southern Maryland and completed his training in July 1954. There he tutored U.S. Marine Corps aviator John Glenn in math and physics. He was a test pilot until January 1957. In 1959, the U.S. Navy sent Stockdale to Stanford University where he received a Master of Arts degree in international relations and comparative Marxist thought in 1962. Stockdale preferred the life of a fighter pilot over academia, but later credited Stoic philosophy with helping him cope as a prisoner of war. On 2 August 1964, while on a DESOTO patrol in the Tonkin Gulf, the destroyer USS Maddox (DD-731) engaged 3 North Vietnamese Navy P-4 torpedo boats from the 135th Torpedo Squadron. After fighting a running gun and torpedo battle, in which Maddox fired over 280 5-inch (130 mm) shells, and the torpedo boats expended their 6 torpedoes (all misses) and hundreds of rounds of 14.5mm machinegun fire; the combatants broke contact. As the torpedo boats turned for their North Vietnamese coastline, four F-8 Crusader fighter aircraft from USS Ticonderoga (CV-14) arrived, and immediately attacked the retreating torpedo boats. Stockdale (commander VF-51 (Fighter Squadron 51)), with Lieutenant (Junior Grade) Richard Hastings attacked torpedo boats T-333 and T-336, while Commander R. F. Mohrhardt and Lieutenant Commander C. E. Southwick attacked torpedo boat T-339. The four F-8 pilots reported scoring no hits with their Zuni rockets, but reported hits on all three torpedo boats with their 20mm cannon. Two nights later, on 4 August 1964, Stockdale was overhead during the second reported attack in the Tonkin Gulf. Unlike the first event, which was an actual sea battle, no Vietnamese forces were, however, believed to have been involved in the second engagement. In the early 1990s, he recounted: "[I] had the best seat in the house to watch that event, and our destroyers were just shooting at phantom targets--there were no PT boats there.... There was nothing there but black water and American fire power." The next morning, on 5 August 1964, President Johnson ordered bombing raids on North Vietnamese military targets which he announced were retaliation for the alleged incident of 4 August. When Stockdale was awoken in the early morning and was told he was to lead these attacks he responded: "Retaliation for what?" Later, while a prisoner of war, he was concerned that he would be forced to reveal this secret about the Vietnam War. On 9 September 1965, while flying from USS Oriskany on a mission over North Vietnam, Stockdale ejected from his Douglas A-4 Skyhawk, which had been struck by enemy fire and completely disabled. He parachuted into a small village, where he was severely beaten and taken prisoner. Stockdale was held as a prisoner of war in the Hoa Lo prison (the infamous "Hanoi Hilton") for the next seven and a half years. As the senior Naval officer, he was one of the primary organizers of prisoner resistance. Tortured routinely and denied medical attention for the severely damaged leg he suffered during capture, Stockdale created and enforced a code of conduct for all prisoners which governed torture, secret communications, and behavior. In the summer of 1969, he was locked in leg irons in a bath stall and routinely tortured and beaten. When told by his captors that he was to be paraded in public, Stockdale slit his scalp with a razor to purposely disfigure himself so that his captors could not use him as propaganda. When they covered his head with a hat, he beat himself with a stool until his face was swollen beyond recognition. When Stockdale was discovered with information that could implicate his friends' "black activities", he slit his wrists so they could not torture him into confession. Early in Stockdale's captivity, his wife, Sybil Stockdale, organized The League of American Families of POWs and MIAs, with other wives of servicemen who were in similar circumstances. By 1968, she and her organization, which called for the President and the U.S. Congress to publicly acknowledge the mistreatment of the POWs (something that had never been done despite evidence of gross mistreatment), gained the attention of the American press. Sybil Stockdale personally made these demands known at the Paris Peace Talks. Stockdale was one of eleven U.S. military prisoners known as the "Alcatraz Gang": George Thomas Coker, USN; George G. McKnight, USAF; Jeremiah Denton, USN (he graduated with Stockdale from the Naval Academy); Harry Jenkins, USN; Sam Johnson, USAF; James Mulligan, USN; Howard Rutledge, USN; Robert Shumaker, USN (originated the name "Hanoi Hilton"); Ronald Storz, USAF (died in captivity); and Nels Tanner, USN. Because they had been resistance leaders they were separated from other captives and placed in solitary confinement in "Alcatraz", a special facility in a courtyard behind the North Vietnamese Ministry of National Defense, located about one mile away from Hoa Lo Prison. In Alcatraz, each of the prisoners was kept in an individual windowless and concrete cell measuring 3 by 9 feet (0.9 by 2.7 m) with a light bulb kept on around the clock, and locked in leg irons each night. Of the eleven, Storz died in captivity there in 1970. CANNOTANSWER

What happened during those 7.5 years?

Tortured routinely and denied medical attention for the severely damaged leg he suffered during capture,