How come Sauron wasn't able to detect Sam in the last chapter of The Two Towers? I'm pretty sure he wore it longer than Frodo in Amon Hen, and Frodo was detected in the latter, was he not? Plus, Sam didn't only wear it for several minutes, he wore it in Mordor... is there any reason why Sauron didn't spot him ? Even if there was something happenening elsewhere, didn't he detect the presence of the ring as soon as Frodo put it on while inside Mountain Doom? And this was while a battle was being fought in his front door, so just how the hell did he not detect Sam?
According to The Tale of Years, Appendix B of the Lord of the Rings, the following happened between the 12th and 14th of March, 3019:
12 Gollum leads Frodo into Shelob's lair. Faramir retreats to the Causeway Forts. Théoden camps under Minrimmon. Aragorn drives the enemy towards Pelargir. The Ents defeat the invaders of Rohan.
13 Frodo captured by the Orcs of Cirith Ungol. The Pelennor is over-run. Faramir is wounded. Aragorn reaches Pelargir and captures the fleet. Théoden in Drúadan Forest.
14 Samwise finds Frodo in the Tower. Minas Tirith is besieged. The Rohirrim led by the Wild Men come to the Grey Wood.
These are the days around these events you mention, and I purposefully brought the entire events of those days, because they were all explicitly made to be a diversion, a distraction for Sauron to divert his eye from his own back door and allow Frodo and Sam to enter Mordor.
In Chapter 9 of The Return of the King, The Last Debate, Aragorn mentions that he had purposefully shown himself to Sauron through the Palantir and challenged him, revealing himself as the Heir of Isildur. Since Sauron, as Gandalf says there, "knows that this precious thing which he lost has been found again", and knows that "there are some among us with strength enough to wield it", then Sauron has entered a holding pattern, watching the armies of Gondor and her allies and waiting for one of them to make a move:
His Eye is now straining towards us, blind almost to all else that is moving. So we must keep it. Therein lies all our hope. This, then, is my counsel. We have not the Ring. In wisdom or great folly it has been sent away to be destroyed, lest it destroy us. Without it we cannot by force defeat his force. But we must at all costs keep his Eye from his true peril. We cannot achieve victory by arms, but by arms we can give the Ring-bearer his only chance, frail though it be.
and later, when it is proposed that the army attack Minas Morgul:
For if the Ring-bearer had indeed attempted that way, then above all they should not draw the Eye of Mordor thither.
It would appear then, from these quotes, that Sauron would not automatically notice anyone putting on the ring, even in Mordor. It's too close to him, right under his nose, but his attention is focused elsewhere. That is why the armies of Gondor threw themselves in a suicide mission at the Black Gates, to keep it that way.
You might argue that later on, in the Cracks of Doom, Frodo puts on the Ring and Sauron notices instantly, but the case there is different. Frodo doesn't simply put it on, he also claims it as his own, and thus claims the power of Sauron, invested in the ring, as his own. Here it is, from The Return of the King, Book VI, ch. 3, emphasis mine:
And far away, as Frodo put on the Ring and claimed it for his own, even in Sammath Naur the very heart of his realm, the Power in Barad-dûr was shaken, and the Tower trembled from its foundations to its proud and bitter crown. The Dark Lord was suddenly aware of him, and his Eye piercing all shadows looked across the plain to the door that he had made.
The second emphasis, specifically, shows that this wasn't simply a matter of noticing, but of Sauron's power being threatened, which would naturally draw his eye.