-
1. Re: Images and portlets
peterj Nov 23, 2006 10:33 PM (in response to justin_sane)Assume you have an image file located at image/some.gif. To access this from a JSP within your portlet, do this:
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %> <portlet:defineObjects/> <img src="<%= renderRequest.getContextPath() %>/image/some.gif" />
The context path obtained from the render request provides the proper context.
Of course, you can create a similar < img > tag from within the portlet itself (I prefer letting the JSP build the user interface). -
2. Re: Images and portlets
justin_sane Nov 24, 2006 5:36 AM (in response to justin_sane)I've tried that, and nothing...
In the source code of the HTML page there is:
But I put that image everywhere, and nothing...
I even created a File, just to see it would read, and it does...
Strangely with this:
java.io.File file = new java.io.File(renderRequest.getContextPath()+"/images/dodemo.gif");
out.println(file.getAbsolutePath());
I got C:\tester\images\dodemo.gif! -
3. Re: Images and portlets
pl.de Nov 24, 2006 5:53 AM (in response to justin_sane)Do you have a running Portlet? (A war file with the right structure, depolyable and outputting some text?
If yes try this:
1. create the image folder and copy imagesyour app * | + - - + - - WEB-INF (your web- folder, you should have already) | + - index.html | + - - + - - images (NEW) + myImage.jpg (NEW)
2. link your image -
4. Re: Images and portlets
justin_sane Nov 24, 2006 6:30 AM (in response to justin_sane)Finally got it running.
The problem was that my ecllipse project got the directory of the images in the wrong place, so it didn't exported it to the war file.
I tried to put the files by hand but, nothing, because it shoul be inside the war.
So many time lost with this, how stupid of me?!
Than you for your help! -
5. Re: Images and portlets
peterj Nov 24, 2006 3:53 PM (in response to justin_sane)Now you know why I don't trust Eclipse (or any IDE) to do my builds or packaging. I always use Maven 2, or Ant, and I have yet to be surprised. But I am constantly helping people with strange problems where code works for me but not for them only to find out later that they were running/building/packaging within Eclipse or NetBeans.
Be that as it may, I am glad you got it running!