Win a copy of Head First Android this week in the Android forum!

Mohmedabbas Burmawala

Greenhorn
+ Follow
since Jun 16, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mohmedabbas Burmawala

Hi,

We had almost the same requirement viz. rendering multiple images in a single web page, the images to be constructed (i.e. gathered) at runtime at server side. The way we accomplished is:
a) Wrote JSP custom tag handler which writes the image file content to a ServletOutputStream
ServletOutputStream outputStream = pageContext.getResponse().getOutputStream();
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream,"UTF-8");
BufferedInputStream bufferedinputstream;
byte abyte0[] = new byte[4096];
int bytesRead;

bufferedinputstream = new BufferedInputStream(new FileInputStream(new File(fileName)));

while((bytesRead = bufferedinputstream.read(abyte0, 0, 4096)) != -1)
outputStream.write(abyte0, 0, bytesRead);

outputStreamWriter.flush();
outputStreamWriter.close();
bufferedinputstream.close();

b) Wrote a JSP which uses this custom tag. Call it "externalImg.jsp". One attribute that it expects (and this it inturn passes to custom tag) is the file name.
<externalimg:gen fileName="<%=request.getParameter(\"externalFileName\")%>" />


c) Wrote Main.jsp which uses img tag with src = <<the_JSP_created_in_step b>>
<img src="externalImg.jsp?externalFileName=abc.jpg"/>
<img src="externalImg.jsp?externalFileName=def.jpg"/>

Hoping that this might help somebody.


12 years ago