No one can tell you how to grieve or how to cope - instincts are an amazing thing.
This is the reason, however, that my husband and I chose not to find out the gender of our children before their birth. If you only focus on the baby, a healthy baby, you can't be disappointed.
We've not dealt with a miscarriage. But, take comfort in knowing that almost 1/2 of all pregnancies naturally end - it is because something is wrong with the developing fetus, and nature knows it's not appropriate to bring that child into the world.
In our case, we don't know if we'll be able to have more children after I went through 5 months of chemo almost immediately after our 2nd child's birth. I should be able to conceive, but I don't know if it's wise to bring another child into the world in the event I have a recurrence and have few options left to treat my cancer.
I learned in a very short period of time how important is to love your children unconditionally - boy, girl, sensitive, smart, dominant, passive. Whatever they end-up being, nurture them, love them and teach them the important lessons of life.
Good luck - I hope you enjoy this baby and can celebrate his health and happiness.