This happened all the time. In the Ultimate Marvel Universe, Sandman was once separated into jars and frozen by Iron Man. Can you imagine being broken up into pieces and kept alive in separate jars? Probably not, but at least you could argue Sandman was unconscious for that. Our Spider-Man from the original Marvel dimension took madness-inducing incarceration to the next level.
Spider-Man theorized that Sandman couldn't have been just a pile of sand, since that makes no goddamn sense. It made slightly more sense that his consciousness had to be contained in one single magic grain of sand, and all they had to do was capture it. So he hatched a plan. He created a smartphone app that transmitted signals to Sandman's brain to force him to transform into different shapes. We apologize for the word salad, but comics are very strange.
If you download the real-life Marvel companion app, they'll send you an explanation for this bullshit.
Spider-Man knew if they kept fucking with him, they'd eventually find the single grain of sand containing his soul. So he hit a button on his phone that forced Sandman to transform into the shape of his own estranged daughter, Keemia. We're not kidding.
Dude. Dude. Did you just hijack my brainwaves to turn my crotch into my ... my daughter?
Once they found the grain that contained Flint's mind, it was simply a matter of trapping it in a web and locking it away. Think about that for a second -- people go insane in solitary confinement after days, and this was solitary confinement beyond all reason. They locked this man away without eyes, ears, or a mouth to scream. Time would stretch infinitely, and none of your prayers could even be asked, much less answered. That's a living Hell. If they let Sandman out after a month and told him it was now the year 1 zillion, he'd say, "Sand! Sand! Sand!!!!" Which is Sandmadness talk for, "I 100 percent believe you."