In my jsp page in tag (img src="upload/<%=a.getUrlimmagine()%>"
) i have this error
Bad value in "upload/ " for attribute "src" on element "img":DOUBLE_WHITE SPACE in PATH
How can I solve it?
In my jsp page in tag (img src="upload/<%=a.getUrlimmagine()%>"
) i have this error
Bad value in "upload/ " for attribute "src" on element "img":DOUBLE_WHITE SPACE in PATH
How can I solve it?
You would need to use the replaceAll method for String:
<img src="upload/<%=a.getUrlimmagine().replaceAll(" ", "%20")%>" />
Because URLs should not have spaces (see : Are URLs allowed to have a space in them?
) you should encode your url so the unsafe characters will be replaced with some strings representing them (i.e. space becoming %20
)
So you either do this in the getUrlimmagine()
in your bean or do the encoding in the jsp page.
If you are sure that the only unsafe charcter in your image names is spaces so you can use String.replace()
in the backing bean or use the JSTL replace
function h in your jsp page
otherwise if you want the cleanest solution, you should definitely read this article : What every web developer must know about URL encoding by Stéphane Épardaud
A cleaner solution to get the same result without using JSP expression is in this answer by BalusC