Servlet - File location -


i working servlet in eclipse (dynamic web project) . have placed image file in web content folder sub-folder pics. there images pic1.jpg , etc.

 bufferedinputstream bin = new bufferedinputstream(new fileinputstream(new file(location))); 

what location should give in order retrieve these files?

try this

servletcontext ctx=getservletcontext(); inputstream in = ctx.getresourceasstream("/pics/pic1.jpg"); 

getresourceasstream() requires start "/" represents root of web app.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -