my dog learned polymorphism*
The moose likes JSP and the fly likes Image Display problem 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 » Java » JSP
Reply locked New topic
Author

Image Display problem

Simpson Kumar
Ranch Hand

Joined: Mar 19, 2008
Posts: 261
in our application we have to display 4 different images in a popup window (small external page), based on the images, user can select in the main page. i can open the popup window but I can't see the images in popup window.

I tried to do many paths where the images are stored, but no use. how can I display the images and what path I need to place in my popup jsp?

here is the code written.



Thanks,
Kumar
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41089
    
  44
This may help: http://faq.javaranch.com/java/RelativeLinks


Ping & DNS - my free Android networking tools app
K Kiran Kumar
Ranch Hand

Joined: Jan 04, 2006
Posts: 109
Try out the following path.
<img src="./pages/jpg/flower_header.jpg" width="150" height="50"....

The key is for the correct path depends on the context path (request.getContextPath())of the application.

For example if your context path is upto webcontent in a/b/webcontent/images/*.images, use ./images/someimage.jpeg
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Originally posted by K Kiran Kumar:
use ./images/someimage.jpeg
Not a good idea. Use context-relative links as spelled out in the FAQ rather than page-relative links.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Simpson Kumar
Ranch Hand

Joined: Mar 19, 2008
Posts: 261
thank you , it is working now.
I used request.getContextPath() + "/pages/jpg/sports_header.jpg"; and getting image. and the path in logs showing

but I applied same path to generated PDF file, but its not working and the path in the logs showing where the image doesn't exists (with C: folder path). and the path is wrong

how can i get images in pdf file?
Simpson Kumar
Ranch Hand

Joined: Mar 19, 2008
Posts: 261
Anyone please update on this???
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Please read this.

What does the PDF file have to do with the JPG file? If you want an answer, you need to be clear with the question.
Simpson Kumar
Ranch Hand

Joined: Mar 19, 2008
Posts: 261
Actually My PDF file contains data ans as well as images. I can create the data into the PDF and when it comes to add images, I can't find the exact path to attach. the same path I applied to jsps and I can see the images in jsps.

is there any alternate way to add image to pdf rather than
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

I still have no idea what your code has to do with PDFs.
Simpson Kumar
Ranch Hand

Joined: Mar 19, 2008
Posts: 261
Actually its completely related to PDF generation (other tools), I added the same question in other tools topic but i didn't get any response to this. I asked in jsps and I got good results when comes to display images in jsp, but still getting error in PDF generation. If you understand the PDF related code, then I will attach to this topic.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41089
    
  44
If you're getting an error, then you should tell us what that error is.

If it's related to a file path, how have you made sure that the path is correct? How have you made sure that all permissions are set so that the servlet container can access the file?
Simpson Kumar
Ranch Hand

Joined: Mar 19, 2008
Posts: 261
the error i got it
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Originally posted by sumant kuchipudi:
Actually its completely related to PDF generation (other tools), I added the same question in other tools topic but i didn't get any response to this.

Ah I see what's happened. This actually has nothing to do with the original question, and is a self-hijack duplicate of your other post. Please don't do that. Starting a new question in an existing post is confusing, and also do not cross-post the same question in multiple forums.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Image Display problem
 
Similar Threads
Problem in importing html file in jsp
HTML validation errors
Help with script, please!
Getting search results on same search page
JSP and XML