I have uploaded images to server machine folder like c:images. for this i have written "web.xml" <context-param> <description>Location to display uploaded file</description> <param-name>file-display</param-name> <param-value> C:/images/ </param-value> </context-param>
it is uploading perfectly well. Now i need to display those images in a jsp with <img src=""/>
tag.
i am finding the path using
filepath = getServletContext().getInitParameter("file-display");
in servlet and also attached image name. but how to represent in jsp with" <img src=""/>
" tag. is there another way to diplay images in jsp from server location folder.
You should be able to access the ServletContext
in jsp using the predefined application
variable:
application.getInitParameter("file-display");
If you are using Servlet API 3.0 (for EL 2.2, which supports calling methods in expressions) you can do:
${application.getInitParameter("file-display")}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.