Yes i agree with the answer but setStatus only sets the type of http message but does not trigger the response message[Correct me if i am wrong]
I want to send a response to the POST message as 200 ok and then start executing a logic.
Regarding my logic it contains some database related operations and then triggers the GET message to the thirdparty server.
I Hope i am clear with my question.
I think there is a more fundamental design issue here. If you send a 200 to the other server before you finish processing and then your processing fails, the other server would have falsely got a positive response. You need to find ways to speed up your processing or increase the timeout for the other server.
If you are ok with the false positive then this is fundamentally an asynchronous call. Your servlet can just put a message is something like a JMS queue and reply back with a 200OK to the other server. You will then have some kind of a message listener or MDB to process this JMS message. There are other ways to process anything asynchronously - such as EJB timers, Quartz timers or your own thread pool.
PS: Do not create your own threads in servlets. If you really must, then use a threadpool such as the one provided by Executors.newFixedThreadPoolExecutor() on JDK 5+