Twigs
If you are only going to keep a dragonfly in a jar for a few hours to observe and show others, it is best to put a small twig or two in the jar to give it something to rest on. It won't be able to secure itself on the smooth sides of a glass jar. It is also necessary to make sure there are sufficient air holes to allow the dragonfly to get enough oxygen.
Live Insects
If you will be keeping the dragonfly overnight or trying to raise it, an aquarium will provide more of the space it needs to survive compared to a jar. No matter what container you use, it is necessary to add live insects daily in order to feed the dragonfly. They will consume most types of insects, such as gnats, mosquitoes, flies and moths.
To Kill the Dragonfly
If your intention is to preserve the dragonfly and taxidermy it, the best thing to add to the jar is a few drops of acetone. The acetone will suffocate and kill it within a few minutes. It is important to straighten the abdomen on the dragonfly and make any other adjustments to its body immediately after death while it is still flexible.
For Nymphs
Dragonfly nymphs are aquatic. If you are keeping one in a jar to raise or for observation, adding water from the pool, creek, or puddle you got it from is better than tap water. It will have the pH and chemistry the nymph is used to. If keeping the nymph for longer, feed it by putting worms, mosquito larvae and other aquatic bugs into the jar. The water will need to be changed regularly.