WASHINGTON - Military leaders are telling commanders to get their troops in line and refrain from misconduct such as urinating on enemy corpses, in a sharp response to the tasteless photos and other disturbing examples of bad behavior that have enraged Afghans and complicated war-fighting.

The broader message to shore up discipline in the ranks was expected to be underscored by Defense Secretary Leon E. Panetta in remarks Friday at Fort Benning, Ga.

The Army and Marine Corps chiefs have focused on discipline in recent talks to midlevel commanders around the country.

They say they recognize that part of the problem may be leadership stumbles by the young officers who have shouldered much of the burden of wars in Iraq and Afghanistan.

"Maybe we've gotten overconfident, and maybe we've gotten a little bit comfortable in our young leaders," Gen. Ray Odierno, the Army chief of staff, said in an interview Thursday. "Realizing that they are young, they don't have a lot of experiences. We have to continue to assist them so they understand what is expected of them."

Marine Corps Commandant Gen. James Amos was blunter.

"We are allowing our standards to erode," he wrote his commanders. "A number of recent widely publicized incidents have brought discredit on the Marine Corps and reverberated at the strategic level. The undisciplined conduct represented in these incidents threatens to overshadow all our good work and sacrifice."

Panetta, in his first personal appeal to troops on the issue, planned to remind them that they are representing the American people and that the nation's greatness lies not in its ships and fighter jets, but the character and standards of its armed forces.

Senior leaders have warned for several years about a deterioration of discipline that may have contributed to increased substance abuse, suicides, domestic abuse and other problems.

Late last year, Lt. Gen. Mark Hertling, who now commands U.S. Army Europe, suggested that while only a small percentage of soldiers lack discipline, "if you allow that to go unnoticed, it becomes cancerous."

In January, Marines were found to have made a video showing them urinating on Afghan insurgents' corpses. In February, troops mistakenly burned copies of the Quran, which led to violent protests and revenge killings of six Americans. In March, a U.S. soldier left his base and allegedly killed 17 civilians, mainly women and children.

Last month, newly revealed photographs showed U.S. soldiers posing in 2010 with Afghan police holding the severed legs of a suicide bomber.

Gen. John Allen, the top U.S. commander in Afghanistan, has expressed concern about the impact that those incidents have had on the war, according to a senior defense official. Allen believes that a number of major setbacks in the last six months have resulted from moral, not operational, failures, said the official, who spoke on condition of anonymity to discuss internal assessments.

Insurgents have used the incidents to incite violence and undermine U.S. efforts to win over the Afghan people, considered critical to counterterrorism operations.

The incidents have reinforced the perception of Americans as unfriendly or occupying forces who do not understand the culture or the religion of the people they are supposed to protect.