my dog learned polymorphism*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html:img NullPointerException" Watch "html:img NullPointerException" New topic
Author

html:img NullPointerException

sarah smith
Greenhorn

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,
~{S}~
[ September 30, 2005: Message edited by: sarahl2 ]
sarah smith
Greenhorn

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
Greenhorn

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

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

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 'mydomain.com/myapp/', your reference must be '/myapp/images/etc.gif'.


-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
 
Consider Paul's rocket mass heater.
 
subject: html:img NullPointerException
 
Similar Threads
logic:forward problem
Struts in Websphere Application Developer 5
Internationalization login thru to...
re:struts dynamic radio buttons
images not display on Struts forwarding JSP page