This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
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

Problem in displaying an image

 
Siva Sekhar
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...
I am trying to display an image using servlets and tomcat.
My project folder structure is- Tomcat/webapps/sample project/
In that i have images and WEB-INf folders.

I am trying the following code but it is not displaying the image.
can any one help me in this...




[ November 04, 2008: Message edited by: Siva Sekhar ]
[ November 04, 2008: Message edited by: Siva Sekhar ]
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly please make use of code tags.Unformatted code is difficult to read and results in less response for your post. Read this for more information. You can edit your current post to add code tags by clicking .


the src should be specified with forward slashes(/).
 
Siva Sekhar
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried by changing the "\\" to "/"



and I also tried by giving the path to "./images/nature.jpg"
But the image is not displayed.

I am working on this from last 1 and half day...

 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and I also tried by giving the path to "./images/nature.jpg"


there should be no dot(.) in the beginning of the path.
 
Siva Sekhar
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amit,

Thanks a lot.

I got the solution.
In my program "content" is wrong.
I set the content as "Image" but I am sending Html response.
That is the mistake.
Next as you mentioned I change the source path also.
Once again Thanks a lot....


-sekhar
[ November 05, 2008: Message edited by: Siva Sekhar ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic