tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Reynir Þór Hübner <rey...@hugsmidjan.is>
Subject Re: sendRedirect without changing the URL possible ?
Date Fri, 30 Apr 2004 15:58:25 GMT
Hi,

Shapira, Yoav wrote:

> 
> (A RequestDispatcher#forward is one way to keep the URL the same,
> 

Another way would be using streams, then you could either proxy requests 
via URLConnection or HTTPClient or similar, or use java.io for static 
files, and then write the inputstream to the response :

try
{
URL url = new URL(yourpath);
InputStream instr = url.getInputStream ();
OutputStream outstr = res.getOutputStream();
while ( (true))
{
	int in=instr.read();
	// write file to response.
	outstr.write(in);
	if ((in==-1)) break;
}
outstr.close();
}
catch (Exception e)
{
	e.printStackTrace(System.out);
}

This is maybe not a good idea in all senses (and the code above has not 
been tested, and is probably not very fast), but may help you doing what 
ever you are trying to do.  This way you can reach remote hosts. You 
need to add some functionality if you need keep track of sessions, 
cookies, authentications etc. Anything is possible...

hope it helps
-reynir@hugsmidjan.is



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message