i want to display image at browser with help 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 it is not display images. Where is the problem. How can i resolve it???
file1.xml. Did you try wrapping the img src with double quotes?