Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

html:img NullPointerException

 
sarah smith
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
~{S}~
[ September 30, 2005: Message edited by: sarahl2 ]
 
sarah smith
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:

<html:image page="/whatever/myimage.gif"/>
 
sarah smith
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Same error

Thank you for your suggestion, though.
 
alan do
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you use '/' to start out your URL, you must include the context root. if your app is 'mydomain.com/myapp/', your reference must be '/myapp/images/etc.gif'.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic