Title

Monday, 19 January 2015

Unable to use resources in production mode with tomcat


I developed an application using GWT. It works alright in development mode. On the other hand when deployed all resources become unavailable. For example:

I have an image in:

mydomain.com/images/myimage.png

But when I deploy the application the image url becomes:

mydomain.com:8080/images/myimage.png

I already checked and the image is there (mydomain.com/images/myimage.png) the problem is about the used port.

I already tried the following ways to access my resources:

<g:Image url="/images/myimage.png" />

or

<g:Image url="../images/myimage.png" />

Both work in development mode but not in production with tomcat.

What am I doing wrong?

Also I'm deploying the app in webapps folder and the resources in the public_html folder.

Thank you

Answer

Did you mean url="../images/myimage.png" to actually be url="./images/myimage.png" or do you actually have them in the directory above where your using them?

Answer2

Try appending HttpServletRequest#getContextPath for your internal URLs:

url="${request.contextPath}/images/myimage.png"

No comments:

Post a Comment