This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Struts and the fly likes html:img NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html:img NullPointerException" Watch "html:img NullPointerException" New topic

html:img NullPointerException

sarah smith

Joined: Sep 30, 2005
Posts: 3
I'm very new to struts - but I'm trying to set up a basic form page, and I'd like to place an image on it. I created an images directory in the same directory as my .jsp page. Then, i created an img tag:

<html:img page='/images/header.jpg'/>

This gives me a NullPointerException, although the file is definitely there.

Here's the whole page:

I created a parallel html page that finds it just fine. Any ideas would be wonderful -
Thanks in advance,
[ September 30, 2005: Message edited by: sarahl2 ]
sarah smith

Joined: Sep 30, 2005
Posts: 3
Ok, I've found a bit more information on this - not sure if it will clarify at all. When I added the img tag and opened the jsp page it was actually running my java code with an empty request. Naturally, since it was a totally empty request, there were no parameters and hence the NullPointer. So, i went into my java and put a catch for that.

Now there's no null pointer, but there's also no image and no error message to give me any clue about why.

Any ideas? This one's makin' me crazy.
Aash Patel

Joined: Sep 14, 2005
Posts: 24
Try this:

<html:image page="/whatever/myimage.gif"/>
sarah smith

Joined: Sep 30, 2005
Posts: 3
Same error

Thank you for your suggestion, though.
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
if you use '/' to start out your URL, you must include the context root. if your app is '', your reference must be '/myapp/images/etc.gif'.

-/a<br />certified slacker...yes, my last name is 'do' - <a href="" target="_blank" rel="nofollow"></a>
jQuery in Action, 2nd edition
subject: html:img NullPointerException
Similar Threads
images not display on Struts forwarding JSP page
logic:forward problem
Internationalization login thru to...
Struts in Websphere Application Developer 5
re:struts dynamic radio buttons