on 04-11-2005 4:10 PM
Hello, I'm try to display a JSP page with some images.
In a Developer Studio I obtain a correct visualization but after deploy, on a http url, I see only a html structure of the file without images. I used this structure:
webContent: contains a jsp file
webContent/common: contains a gif files.
In a jsp file I refer the image with:
<img src="common/apri_inpopup.gif">
Where is my error ?
Thanks in advance
Gianfranco
Hi Gianfranco and everyone,
I passed through the same problem and figured out the root cause. Maybe Gianfranco is not interested in the answer more than 2 years later, but I was! So, for the record, the Quick Car Rental tutorial defines QuickOrderProcessorServlet as the root (/). This way every request is sent to servlet processing, even requests for images... The easier solution is defining the servlet as /action or something, and leave the root free for subfolders, as /images. This way the direct call suggested above will work as expected. For form processing, just put the attribute action="/action" on the forms and you'll be sent to the Servlet.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gianfranco,
I would recommend you to keep the images in your images directory and use the following
String imagePath = componentRequest.getWebResourcePath() + "/images/image.jpg"
and use the image path variable in the src attribute of the img tag
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prakash,
I've tried your solution but I've obtained an error: componentRequest is not a variable.
I think that it happens because I'm not use an Enterprise Portal component.
So, instead of componentRequest.getWebResourcePath() I try to use request.getContextPath()
but it doesn't give me a solution.
Another doubt: if I try display image with the url:
http://servername:port/contextroot/imagefolder/image.gif
I obtain the jsp but not the image.gif.
Gianfranco
Hi Gianfranco,
did you try to request directly the URL of the image?
i.e. http://servername:port/contextroot/imagefolder/image.gif
And could you try and check the result pls with a simple jsp, containing only
<img src="imagefolder/image.gif" />
Regards
Bojidar
Hi Gianfranco,
You need some more coding. Let say images are stored in <b>dist->images</b> folder then your jsp will the have following code.
<b>
<% String image = componentRequest.getWebResourcePath() + "/images/image.gif"; %>
<img src="<%=image%>">
</b>
if the images are stored in the folder <b>dist->PORTAL-INF->images</b> folders then your jsp will have the following code.
<b>
<% String image = componentRequest.getPrivateResourcePath()() + "/images/image.gif"; %>
<img src="<%=image%>">
</b>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.