java - display image with jsp -


i want display image @ browser of given code

images.jsp

<%@ page contenttype="text/html"%> <%@ pageimport="javax.xml.parsers.documentbuilderfactory,javax.xml.parsers.documentbuilder,org.w3c.dom.*" %> <html> <body><center><table border="2"> <%documentbuilderfactory dbf = documentbuilderfactory.newinstance(); documentbuilder db = dbf.newdocumentbuilder(); document doc = db.parse("\\file1.xml"); nodelist pic1= doc.getelementsbytagname("pic1"); nodelist pic2= doc.getelementsbytagname("pic2"); %>    <tr><td>  <img  border="2" src=<%= pic1.item(0).getfirstchild().getnodevalue() %> width="137" height="140"></td> <td>  <img  border="2" src=<%= pic2.item(0).getfirstchild().getnodevalue() %> width="137"  height="140"> </td>  </tr>  </table>  </center> </body> </html> 

file1.xml

<?xml version="1.0" encoding="utf-8"?>  <images>  <pic1>buldhana.jpg</pic1>  <pic2>buldhana.jpg</pic2>   </images> 

but not display images. problem. how can resolve it???

check html rendered on browser check img tag whats src attribute?? , , should ??

update:

your dir structure should this

jsp file at

c:\program files\apache software foundation\tomcat 5.5\webapps\sampleapp\1.jsp 

image file @

c:\program files\apache software foundation\tomcat 5.5\webapps\sampleapp\images\1.jpg 

in browser address bar

http://localhost:8080/sampleapp/1.jsp 

html code

<img src="images/1.jpg"/> 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -