views:

32

answers:

1

in my application all jsp pages in jsps folder i give the path in index.jsp:<% response.sendRedirect(response.encodeRedirectURL("/Projectname/jsps/main.jsp")); %> although main.jsp is show but it does not show logo, graphics etc. all the js and logo files in js folder which is parallel to jsps and WEB-INF folders. now structure is: ProjectName>WebContent>Company1,WEB-INF,index.jsp,jsps>here all jsp's

in Company1 folder having some CSS file.but graphics are not shown. it work fine when all jsp's was in Company1 folder.

+2  A: 

"Graphics" as you call it (images, CSS, etc), are not loaded in webserver, but in webbrowser by a simple HTTP request. Relative URL's are relative to the current request URL (as you see in browser address bar), not to the folder structure in the server side.

In order to figure the correct relative URL, you need to know the absolute URL of both the JSP page and the image file. For example http://example.com/jsps/page.jsp and http://example.com/images/image.gif. In that case, the relative URL to the image as opposed from the JSP page would be one folder up and then the filename: ../images/image.gif Alternatively you can also use a domain-relative URL, starting with a leading slash: /images/image.gif.

If you're using CSS background images like selector { background: url('foo.gif'); }, then you need to know that those URL's are relative to the URL of the CSS file itself, not to the JSP page which is including the CSS file.

If you can't get it to work, update your question to include the absolute URL of both the JSP page and the image file, then we can assist you in extracting the correct relative URL.

BalusC
Thanks Mr.Scholtz.
singh