problem while i am sending image as a stream between jsp pages

Hi,I want to send the image from one jsp page to another jsp via stream.Help to continue the process...
[124 byte] By [AVAJa] at [2007-11-27 8:23:15]
# 1
You can't pass a 'stream' between two JSPs since the connection is closed after a request. You should, instead, either put the object into the session or put some sort of referenece to it's location.What exactly are you trying to achieve here?
nogoodatcodinga at 2007-7-12 20:12:04 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Thak you for ur reply.

But in Servlet-Chaining concept, one servlet output stream passed to another servlet and goes on...

like that, is possible to do same in jsp.

My actual task is to send the image from one jsp page to another, the sample code i paste here

<%@ page import="java.io.*" autoFlush="true" %>

<%

System.out.println("======Send.jsp=====");

ServletContext sercon = getServletContext();

String filename = sercon.getRealPath("/logo.png");

RequestDispatcher rd = sercon.getRequestDispatcher ( "/read.jsp" ) ;

InputStream file=new BufferedInputStream(new FileInputStream(filename));

int i,j=0;

try

{

OutputStream os=response.getOutputStream();

while((i=file.read())!=-1)

{

j++;

os.write((byte)i);

}

System.out.println("Bytes Read : "+j);

rd.forward(request,response);

os.flush();

file.close();

}

catch(Exception e)

{

System.out.println("Error"+j);

}

%>

<%@ page import="javax.swing.*,java.io.*,java.util.*"%>

<%

byte[] by;

int i,j=0;

System.out.println("======Read.jsp=====");

response.setContentType("image/png");

InputStream is=request.getInputStream();

System.out.println("In Read.jsp read bytes : "+is.available());

ByteArrayOutputStream os=new ByteArrayOutputStream();

while((i=is.read())!=-1)

{

j++;

os.write(i);

}

by=os.toByteArray();

out.println(by+"\n"+i);

os.close();

is.close();

%>

If i run this code (send.jsp) the image is displayed in the current page itself, and not forward to read.jsp

Is any other alternative solutions then point out.

AVAJa at 2007-7-12 20:12:04 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...