How to render casted shadow on surface only
Cycles Render
Select the surface object, go to Object / Cycles settings and check Shadow Catcher.
In Render / Film, check Transparent.
Blender Render
Select the surface object, go to Material / Shadow, check Shadows Only.
In Render / Shading / Alpha, select Transparent.