• Post Reply Bookmark Topic Watch Topic
  • New Topic

What would be the code for jsp to show an image file with text?!?  RSS feed

 
darren schild
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need some help, I'm failing here, anything would be much appreciated.
I am trying to have a servlet create a jsp servlet that has an image file (either gif or jpg) along with some text.
I get the text fields but the image is a red X with a border, no image?
Does the servlet need to pass the file?
Can anyone give me a Code example?
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
boatnjunky
Welcome to the Java Ranch, we hope you�ll enjoy visiting as a regular however,
your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy.
Thanks again and we hope to see you around the ranch!!

As for your problem, do you just want it to show up in someones browser? In that case you just use the HTML img tag.
<img src="pathToImage" width="width" height="height">
It sounds like thepath to the image is not correct. If your getting an x it sounds like the browser is recognizing the tag but not finding the image. Double check the path you have to the image.
hope that helps
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually the problem when designing an app is forgetting to include the application context in the path. If you have a JSP in (for example)
/webapps/myApp/myJSP.jsp
and you call it as
mydomain.com/myApp/myJSP.jsp
and your image is in
/webapps/myApp/images/myImage.jpg
Then you have to refer to images as
<img src="/myApp/images/myImage.jsp">
Then again, this might not be your problem at all...
Dave
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!