Subject: ANT - Importing Images into WAR file in struts
Posted By: aadz5 Post Date: 1/21/2006 6:09:41 PM
Hiya Guys,

everytime I build my struts project, I copy my images over to the web-inf/Images directory.  Everytime I load a jsp, the image file does not load.  Here is the source of the html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
    <title>Untitled</title>
</head>

<body>
<table>
    <tr>
        <td><img src="MNAMainPic.jpg" width="800" height="200"></td>
    </tr>
    <tr>
    </tr>
    <tr>
    </tr>
</table>


</body>
</html>

here is my ant file:

<!-- Copy any resource or configuration files -->
    <target name="resources">
        <copy todir="classes" includeEmptyDirs="no">
            <fileset dir="src/java">
            <patternset>
                <include name="**/*.conf"/>
                <include name="**/*.properties"/>
                <include name="**/*.xml"/>
            </patternset>
            </fileset>
        </copy>
        <copy todir="Images" includeEmptyDirs="no">
            <fileset dir="Images">
                <patternset>
                    <include name="**/*.swf"/>
                    <include name="**/*.gif"/>
                    <include name="**/*.jpg"/>
                </patternset>
            </fileset>
        </copy>
    </target>

what am I doing wrong?

Thanks

Adz - Its all about the JSPs baby!
Reply By: panacea Reply Date: 1/21/2006 7:14:27 PM
Two things:

1) Open your .war in WinZip (or WinRAR) and verify that the images are being included.
2) Change the src URL to "Images/MNAMainPic.jpg"

If that fails, try running an HTTP monitor such as Charles (http://www.xk72.com/charles/) to see what image URL is being fetched and what error message the server is returning.

Jon Emerson
http://www.jonemerson.net/

Go to topic 39020

Return to index page 389
Return to index page 388
Return to index page 387
Return to index page 386
Return to index page 385
Return to index page 384
Return to index page 383
Return to index page 382
Return to index page 381
Return to index page 380