This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Firefox doesnt support images

 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my jsp I have a coding like this.

<%= application.getRealPath("images")+"/"+"image1.jpg" %>.

The image appears correctly in IE but it doesnt appear in Firefox. What are the possible reasons for this. Do i need to change the code?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the HTML that gets generated from this, and to which absolute URL does that translate? Is there an image at that URL?
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont have the full coding right now. The path contains a actual image and it displays fine in the IE but in firefox only the image border is displayed.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does "application.getRealPath" do? Is "application" the servlet context? If so, then it can't possibly work, because ServletContext.getRealPath returns a file system path that's valid only on the server, not the browser.
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. The image resides in the web application. How should i handle dynamically changing image paths?
[ August 06, 2007: Message edited by: Dilshan Edirisuriya ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
What does "application.getRealPath" do? Is "application" the servlet context? If so, then it can't possibly work, because ServletContext.getRealPath returns a file system path that's valid only on the server, not the browser.


It can work but only if you're running a brower on the same machine that is hosting the webserver.
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the images are part of your web application, then you should be able to make them relative to your web app (start path with "/")
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is im using netbeans IDE. In netbeans environment there is a build path also same as the development environment. I have uploaded the images to the build path by getting the real path as above.Thats why i'm using the same syntax to acceess the image. Tell me the correct way of doing this.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regardless of the IDE you're using, JEE applications have a spec driven directory structure. If you want your browser to be able to view images directly (if you want to serve them up as static resources) they will need to be located in the correct place within your web application.

There is a link to the Servlet Spec in my signature.
It is worth taking the time to read it.
Chances are, your IDE will not be present in the production environment so it is important that all the developers on your project know how to deploy and debug your app without it.
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then why does it work in Internet Explorer? Then it should not work in both browsers
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dilshan Edirisuriya:
Then why does it work in Internet Explorer? Then it should not work in both browsers


Does it matter?
You're using code that serves up images as local resources; using a path that your users are almost guaranteed not to have on their local machines.
Whether it works in FF on your machine or not, I can assure you it won't work with any browser once you publish it.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dilshan Edirisuriya:
Then it should not work in both browsers

Also, when dealing with client side issues (which, service up local images is..) you can never assume that something will work the same way any two browsers.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic