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
Post a Comment