OK I've sussed it myself.

Got to use the <html:img> tags with a page attribute to get context
relative path.

I need to avoid using <html:base/> in any JSPs because it reveals the
absolute URL to the JSP.

e.g. if I include it I get this appearing in the rendered page source:

<base href="http://localhost:9080/myApp/WEB-INF/pages/index.jsp";>

and that's bad because users shouldn't be able to get to WEB-INF directly
should they?


Rob Breeds




                                                                                       
                                                           
                    Rob                                                                
                                                           
                    Breeds/UK/IBM@       To:     [EMAIL PROTECTED]        
                                                           
                    IBMGB                cc:                                           
                                                           
                                         Subject:     how to refer to images from JSPs 
in WEB-INF?                                                
                    19/10/2001                                                         
                                                           
                    10:40                                                              
                                                           
                    Please respond                                                     
                                                           
                    to struts-user                                                     
                                                           
                                                                                       
                                                           
                                                                                       
                                                           




The Struts example (or I read it somewhere on the husted.com pages)
recommends putting JSPs under the WEB-INF folder so the JSPs can't be
served directly - only by action path. This seems a good thing but I can't
get it to work satisfactorily. And no examples I've found ever put the JSPs
under WEB-INF!

The problem this creates (for me) is that if I want to include an image in
a JSP, and that image is above the WEB-INF directory, how do I refer to it?

Do I use relative links: <IMG SRC="../theimage.gif>  ? This works but will
be a pain to maintain.

I can't use an absolute URL because the JSP doesn't know the web app
context base path and hardcoding the base path would be nasty.

I can't use the <html:base> generated base because that is within the
WEB-INF directory

I can't put images under WEB-INF  because that will reveal the real action
path. e.g. http://host/myapp/WEB-INF/images/theimage.gif and will not show
the image (can't serve from WEB-INF)

Can anyone help please?

Thanks



Rob Breeds






Reply via email to