Coping with not getting the job offer can be broken down into three parts: getting over the rejection, analysis of your candidacy, and moving forward with your job search.
Dealing With Rejection
The first step in getting over not getting hired entails sharing the frustration, disappointment, and anger that accompanies any loss. Talk to a friend or family member and share your feelings in a confidential setting.
Don't say anything negative to the employer because you may want to apply to the organization again in the future. I heard from an employer who received an email saying "Your loss." from a rejected candidate. I can guarantee that the applicant won't be considered for another position at the company.
Recognize that most searches are quite competitive, and many talented candidates are often rejected since only one person can get the job. It is quite likely that the employer is not actually rejecting you, but rather saw another candidate as a (maybe even slightly) better fit. Since hiring decisions are typically quite subjective, it is entirely possible that another recruiter might have chosen you.
Also keep in mind that maybe the hiring manager was right, and this job wasn't the best fit for you and wouldn't have worked out. In that case, the company did you a favor by not hiring you.
What Could You Have Done Differently?
Reflect upon your approach to the hiring process to see if there is anything you could improve upon in the future. Take a step backwards and review your resume, cover letter, interview, and follow up activity. Given what you ultimately learned about the job requirements and people involved, ask yourself if you could have done something differently in order to present yourself more effectively.
In some cases, though not typically, an employer might share some feedback about your candidacy. If you developed a rapport with anyone at the organization, you might approach them with a request for constructive criticism.
Keep Your Job Search Moving Forward
Candidates often lose momentum with their search while waiting to hear if they landed a job. However, it's not a good idea to stop looking until you have accepted a job offer. Even if you get an offer, it might not be what you expected.
If you did put your job search on hold because you thought you were going to be hired, move on with your search with renewed energy as soon as possible. Finding other options, and hopefully getting some positive responses for interviews or networking meetings, will soften the blow of your recent rejection, and help to build your confidence back up.