Using scenes and render layers to composite an object isolated on white background with shadow
Cycles

Here is an example file for you to inspect.

The wiki page for Renderlayers in cycles: 


  Render layers are used to render different objects in the scene into different images. This way they can, for example, be color corrected
  or otherwise manipulated separately and then recomposed in compositing
  later.
  
  Which objects contribute to which render layers are defined by these
  layer settings:
  
  
  Scene Layers: only objects on these layers will contribute to the image.
  Camera Layers: objects on these layers are directly visible to the camera. When an object is in the scene layers but not camera layers,
  it will still cast shadows or be visible in reflections, so it's still
  indirectly visible. This is equivalent to disabling the Camera in the
  Ray Visibility panel for the object. The way this works may be
  somewhat confusing at first, but it's designed such that render layers
  can be recomposed to give the full render, without any missing shadows
  or reflections.
  Mask Layers: objects on these will mask out other objects appearing behind them. This is equivalent to assigning a Holdout
  shader for camera rays to the objects on such layers.
  Exclude Layers: scene layers are shared between all render layers; however sometimes it's useful to leave out some object influence for a
  particular render layer. That's what this option allows you to do.
  


The object is on Scene layer 2, the lights are on Scenelayer 3, and the background is on Scene layer 4.

Transparent is enabled in Properties > Film:



And RGBA is enabled in Output:



The settings for each Renderlayer:

For the Renderlayer to result in only the object, we need to include the lights and the object layers, and disable the background layer (we don't want to exclude entirely, because we want the bounce lighting on the bottom of the object):

 

For the Background, the lights and background layers are enabled, and we exclude the object layer entirely, as we do not want shadows:

 

This one is the same as BG, except we don't exclude the object layer, so shadows cast by our object will be visible:

 

Compositing

Replace the image inputs in your setup with the appropriate Renderlayers:



Result: