how to bring a background task to foreground in google app engine?
This won't work directly as you describe it.
Once a background task is started, it's a background task for its entire existence.  If you want to return some information from the background task to the user, you'll have to add it to the datastore, and have a foreground handler check the datastore for that information.
You may also be able to use the Channel API to have a background task send messages directly to the browser, but I'm not sure if this will work or not (I haven't tried it).
If you give a little more information about exactly what you're trying to accomplish I can try to give more details about how to get it done.
Currently I have tasks running in background. After the tasks are done executing I need to show output. How do I do this in Google App Engine?
Once the tasks are done the only thing I can do is create another task which is supposed to show output or is there any other way?