Assuming you have a fixed jsp page which is then used to by the client to launch the dynamically generated one, you just need to pull the host and port information from the static jsp page's implied request variable.
[Message sent by forum member 'wwwjames']
http://forums.java.net/jive/thread.jspa?messageID=476415