There is a diagnostic mode that you put the ECU in to check the function of the O2 sensor. Check out the factory service manual at
http://www.nissanservicemanual.com
On page EC-31 it gives you a procedure to use to test the front sensor by changing the set screw on the ECU. The sensors do get sluggish, and can reduce MPGs, but I don't think they'll cause an issue like you're having.
In terms of which sensor to replace, typically just the front one. The back one is just a check to make sure the catalytic convertor is working properly, but it's not used for engine control like the front one.
The evap. canisters are sometimes a problem on these trucks. If messing with it fixed your issue for a while, it might be time to replace it. I'd go through the diagnostic steps on EC-20 of the FSM. I'd also look toward a dirty mass air flow sensor... I used to have a '97 hardbody, and it would very occasionally idle low. I sold it to my neighbor, and he mentioned that he occasionally has issues with it idling funny, and cleaning the MAF helps.
Good luck!
Heath