You do know what the response is used for? Let me elaborate.
1) a client connects and makes a request to the server
2) server handles this request by invoking a JSP or servlet
3) server generates a response, this is sent back to the client as HTTP data
4) REQUEST/RESPONSE IS CLOSED
5) client executes javascript
You see the problem? Javascript is executed by the browser after your request finishes. Not only is it run on a completely different machine that your response object lived on, but the javascript executes long after the response has already been sent and closed.