Bear spray can be effective, but only at very close range, and you need to be aware of wind direction or you run the risk of getting it in your own face. You don't want that! Use it in short bursts rather than trying to unload on them. You gotta have nerves of steel to use this stuff effectively against a charging bear and I would consider it as a last resort.
Bear bangers are another good deterrent - more effective than bear spray IMO as they can work at much longer ranges.
Firearms can be effective too, but again it is mostly the noise. Shoot a bear and he will take a minute to die - assuming your shot was fatal. In that minute that bugger can wreak some mayhem, believe me. If you have to shoot a charging bear, try to take a knee or front leg. This will do more to stop or slow it down than a heart/lung shot. Good luck with a head shot unless you are a really good shooter. Even then they say the bullets can actually deflect off the skull. Putting a shot to his nose or face is you best bet for a head shot on a charging bear, but for me, I'm taking his legs out.
I have avoided responding in this thread because my answer could be huge. I have a lot of experience with bears, and there really is no stock answer that holds true in all cases. The biggest thing I can recommend is to remain calm, back away slowly, and do not tun your back on them for any reason. Do not run unless you know for certain you are to be converted to bear poop.
If it is a sow and cub, you are in grave danger and you really do need to get away quickly, but do not just blindly run. Back away quickly but calmly so she knows as soon as possible that you are not a threat. Make yourself big, but do nothing else to attempt to intimidate.
My most recent encounter was just this past Saturday. I was trying to shoot some video in a fairly remote location - on trail, but about a mile past the park boundary, and suddenly there he was, just watching me from about 60-70 yards. He was not displaying any aggressiveness so I was not too alarmed, but on the side of caution I picked up my gear and turned back towards civilization. He followed me for a good 10 minutes but kept his distance to about 70 yards or so.
That was the first time a bear has done that, so I was a bit unnerved by the time he had enough and disappeared. I think he was genuinely curious, most likely bored, and just wanted a better look at me. It was also very hot out, and neither of us had the energy to confront the other.
With the exception of sows with cubs, the vast majority of encounters I have had have been nothing more than a big hairy bum running away through the woods. The sows confront every time until the cub is safely away and then they leave too. I have had them even stand-off my Jeep to the point that I had to back up to avoid her climbing in with us.
Some facts about bears ...
They can in fact run downhill - it is complete nonsense that running down a hill will save you from a bear attack. They are almost as fast going up and down a hill as they are on flat ground.
Grizzlies can climb trees too, but the larger ones are generally too heavy to be very good at it. A young grizzly however, is a pretty good climber.
They are very strong swimmers and can swim for hours.
They are as fast as a race horse and will outlast most humans in endurance
A medium sized black bear can tear the doors right off your vehicle
Just because a bear appears to be ignoring you does not mean that they are. If they know you are there, best to leave or give them a very wide berth.
I could write a book on this topic, but I just don;t have the time. If you have specific questions, feel free to ask and I will do my best to answer.