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
Marshal
Joined: Mar 22, 2005
Posts: 35258
7
posted
0
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
Joined: Apr 22, 2006
Posts: 299
posted
0
Thanks. The image resides in the web application. How should i handle dynamically changing image paths? [ August 06, 2007: Message edited by: Dilshan Edirisuriya ]
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.
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
Joined: Apr 22, 2006
Posts: 299
posted
0
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.
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
Joined: Apr 22, 2006
Posts: 299
posted
0
Then why does it work in Internet Explorer? Then it should not work in both browsers
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.
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.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.