(This has to be a Java question as it simply works in a txt with a HTML extension....)

I have this code:

<html><head><title></title></head><body>
<form id='formulario' action='index.html' method='post'>
<label>Ancho </label><input type='text' name='ancho' id='ancho'><br >
<label>Alto </label><input type='text' name='alto' id='alto'><br >
<label>Izquierda </label><input type='text' name='izquierda' 

id='izquierda'><br >
<label>Horizontales </label><input type='text' name='horizontal' 

id='horizontal'<br >
<label>Verticales</label><input type='text' name='vertical' id='vertical'><br 

>
<label>Crucero </label><input type='text' name='cruzero' id='cruzero'><br >
<label>Marco </label><input type='checkbox' name='marco' id='marco'><br >
<label><input type='radio' name='RadioGroup1' value='1' 

id='piezas'>Piezas</label><br><label><input type='radio' name='RadioGroup1' 

value='0' id='medidas'>Medidas</label><br>
<input type='submit' value='Enviar'></p>
</form><img src='c:\archivo1.jpg' width='500' height='500'></body></html>

Why does this work (displays the image) in the MyEclipse browser and not in IE/Chrome/FF/etc?

Dani AI

Generated

The IDE's internal browser and a full external browser do not always resolve local filesystem image references the same way. The observable difference usually comes from two things: how the page is being served (file:// vs http://) and browser security/same-origin rules that prevent a page served over HTTP from loading arbitrary local files. That explains why the image can appear inside MyEclipse but fails in IE/Chrome/Firefox.

Quick troubleshooting steps that produce an immediate diagnosis:

  • Check how the HTML is opened: a file:// URL or via a local web server (http:// or ).
  • Open the browser DevTools Console/Network tab and look for errors such as "Not allowed to load local resource" or 404s for the image request.
  • Try opening the image directly in the external browser (using a file URI) to confirm filesystem access and permissions.

Practical fixes:

  • Put the image inside the web project (document root) and reference it with a web-relative path. This is the correct approach for sites that will run in browsers.
  • If testing locally, run a simple local server from the project folder instead of double-clicking the HTML file. Example (from the folder with the HTML):
    python -m http.server 8000

    Then load the page at so the image is requested from the same origin.

References: the HTML <img> element usage and origin/security constraints are documented on MDN and the file URI scheme is defined in RFC 8089: img element file URI scheme (RFC 8089).

As and discussed earlier, the root cause is environmental (how the file is referenced and served) rather than a Java issue.

Recommended Answers

All 2 Replies

(This has to be a Java question as it simply works in a txt with a HTML extension....)

I have this code:

<html><head><title></title></head><body>
<form id='formulario' action='index.html' method='post'>
<label>Ancho </label><input type='text' name='ancho' id='ancho'><br >
<label>Alto </label><input type='text' name='alto' id='alto'><br >
<label>Izquierda </label><input type='text' name='izquierda' 

id='izquierda'><br >
<label>Horizontales </label><input type='text' name='horizontal' 

id='horizontal'<br >
<label>Verticales</label><input type='text' name='vertical' id='vertical'><br 

>
<label>Crucero </label><input type='text' name='cruzero' id='cruzero'><br >
<label>Marco </label><input type='checkbox' name='marco' id='marco'><br >
<label><input type='radio' name='RadioGroup1' value='1' 

id='piezas'>Piezas</label><br><label><input type='radio' name='RadioGroup1' 

value='0' id='medidas'>Medidas</label><br>
<input type='submit' value='Enviar'></p>
</form><img src='c:\archivo1.jpg' width='500' height='500'></body></html>

Why does this work (displays the image) in the MyEclipse browser and not in IE/Chrome/FF/etc?

uhm no this is not java-java is not simple text in a file, but rather compiled byte code- this that you show is Hyper Text Markup language/html, your post would be better answered here:http://www.daniweb.com/web-development/web-design/html-and-css/143 however i see no reason why the picture would not be shown, it is good practice in html though-also i heard-to put c:/filename and not c:\filename.

uhm no this is not java-java is not simple text in a file, but rather compiled byte code- this that you show is Hyper Text Markup language/html, your post would be better answered here: however i see no reason why the picture would not be shown, it is good practice in html though-also i heard-to put c:/filename and not c:\filename.

My mistake. I thought it only worked after calling a Java servlet.

It is indeed a HTML error.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.