aspose file tools*
The moose likes Servlets and the fly likes Problem in displaying an image 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 » Java » Servlets
Bookmark "Problem in displaying an image" Watch "Problem in displaying an image" New topic
Author

Problem in displaying an image

Siva Sekhar
Ranch Hand

Joined: Jun 11, 2008
Posts: 37
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

Joined: Jun 06, 2007
Posts: 2713
    
    5

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(/).


SCJP, SCWCD.
|Asking Good Questions|
Siva Sekhar
Ranch Hand

Joined: Jun 11, 2008
Posts: 37
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

Joined: Jun 06, 2007
Posts: 2713
    
    5

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

Joined: Jun 11, 2008
Posts: 37
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in displaying an image
 
Similar Threads
Resizing Large JPG Problem
Java Code to Convert RTF to JPG
file downloader for image downloading not upto the limit....
Image width & height return negative
How to download csv file