Upvoted, because you make a very important point: I think our best course of action is to accept that these things do happen occasionally.
It is very hard to stop all zealots, especially if they act on their own or in small groups. Trying to extend spying, restraining ourselves in our free speech, starting to hunt down people of a certain religion, etc. will only have the opposite effect: stifling democracy and free speech.
The best reaction is to stay calm and continue to be rational: terrorism exists to instill fear in people. However, looking objectively, the chance of being hurt in a terrorist act is fairly slim in most countries. Especially if the problem is treated well, besides smart intelligence, social improvement: ensuring that kids have a future, talk with them before they radicalize, etc.
Not sure why you're being downvoted. You're right: absolute security is impossible. Unfortunately, I can already see more "security" laws on the horizon, because lawmakers have to be seen doing something.
However horrible it may sound, I think our best course of action is to accept that these things do happen occasionally. That doesn't mean we shouldn't fight them, and that doesn't mean we shouldn't do our best to prevent them, but it does mean that we must accept that we'll never get to 100%.
If we can move forward with the idea that we'll do our best to reduce these attacks as much as possible, rather than with the idea that we'll eliminate them, I think the result will be much better.
As for what to do, I think the combination of smart intelligence (as opposed to NSA-style dragnets) and emergency response (to minimize the effects of attacks after they happen) are the way to go.
Edit: whee, downvotes. If you think I'm wrong, or even just right but insensitive, would you mind explaining yourself instead of (or, heck, in addition to) downvoting? I honestly don't see anything wrong with my comment.