java - Accessing Resources from JSP inside WEB-INF -
this question has answer here:
i'm having trouble accessing images , css file jsp stored in web-inf. servlet calls jsp , loads fine page unable find images , css file. i'm new sort of thing , appreciate help. aware there have been questions on in past , i've tried suggestions posed can't seem head around it. here's contents of jsp (i tried bunch of different methods):
<%@ page language="java" contenttype="text/html; charset=iso-8859-1" pageencoding="iso-8859-1"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>title</title> <link rel="stylesheet" type="text/css" href="resources/grid.css"> </head> <body> <!-- main container --> <div class="container_12"></div> <!-- foreground container --> <div class="grid_10 prefix_1 suffix_1"> <img src = "/resources/images/foreground.png"> </div> <!-- header container --> <div class = "grid 8 prefix_2 suffix_2"> <img src = "${pagecontext.request.contextpath}/resources/images/header.png"> <p>test</p> </div> <div class = "clear"></div> <!-- navigation bar container --> <div class = "grid 8 prefix_2 suffix_2"> <img src = "${pagecontext.request.contextpath}/resources/images/navbar.png"> </div> </body> </html>
and here's directory structure:
you can use below find real path of image.
<!-- header container --> <div class = "grid 8 prefix_2 suffix_2"> <img src = "<%= application.getrealpath("/resources/images/header.png") %>"> <p>test</p> </div>
Comments
Post a Comment