file - Java ZK full path to WebContent/img -


i have array of bytes store in disk using zk framework later need retrieve array of bytes , create file the real file need later pass gallery on image using javascript jquery plugin uses following pattern show images.

<h:a href="http://upload.wikimedia.org/wikipedia/commons/thumb/4/46/bohinjsko_jezero_2.jpg/800px-bohinjsko_jezero_2.jpg"> <h:img                     src="http://upload.wikimedia.org/wikipedia/commons/thumb/4/46/bohinjsko_jezero_2.jpg/100px-bohinjsko_jezero_2.jpg"/> 

what have solved far?

i have create file using array of bytes using commonsio ok. wondering if java7 have mehod create file arrayofbytes not important now.

as can see main important thing here plugin needs source file image

<h:img                    src="http://upload.wikimedia.org/wikipedia/commons/thumb/4/46/bohinjsko_jezero_2.jpg/100px-bohinjsko_jezero_2.jpg"/> 

i have create file in temp directory directory unreacheable browser guess because firing error image not found solution create file image inside image folder inside webcontent/image folder works using static images question is..

how can full path app directory programmatically?

c:\app\eclipse\myproject\webcontent\img\temporals  

for later create here temporal file

there better approach have array of bytes of image @ start..

thanks lot..

i believe faux pas write data, during lifetime of web application, web application directory itself. it's worse try reference these files path. these files deleted when application redeployed , in servlet container reference files actual path, reference servlet's path.

depending on setup, don't need write file disk @ all. in end, server needs read file , stream client anyway.

your best option provide servlet streams byte array correct mime type (eg: image/jpeg).
this answer suggests similar.
this answer discusses implementation.
ideal in case if you're working byte array anyway.

another option, leveraging zk, create aimage byte array , render directly.

you can consider serving static content server (probably not straight forward if you're using servlet container tomcat) or use simpler server apache server hosting images.

it's tough recommend without knowing context of question.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -