2 Replies Latest reply on Nov 15, 2004 6:20 AM by ian.fallon

    Simple reference of CSS from JSP doesn't work

    ian.fallon

      OK - I'm a complete newby so bear with me.

      My JSP looks like this:


      <bean:message key="admin.centre"/>
      <html:base/>
      <link type="text/css" rel="stylesheet" href="<html:rewrite page='admin.css'/>" media="all" />


      and the .css file is in the WAR at the same level as the JSP, but I don't see the CSS file. In fact, putting the URL directly in the browser doesn't show the CSS file either. Do I need to do something extra to serve up css files ?

      Regards,

      Ian

        • 1. Re: Simple reference of CSS from JSP doesn't work
          raist_majere

          Your problem is Struts related, but I'll try to help you anyway...
          What's the location of the css file in your WAR file? I mean, is it under the /WEB-INF/ dir? I ask you this because you said it's in the same dir as your JSP, and if using Struts it's recommended that your JSP files that have to be accessed after an action cannot be directly accessible, so they are deployed under that dir. If that's what you have done (if you have your CSS file under the WEB-INF dir) then it's impossible that your browser can access it, so the solution would be to move it to another dir that is not under yout WEB-INF dir. Another error i've seen you made is that, as said in the javadoc of the LinkTag (from which RewriteTag inherits the "page" attribute), the page attribute must begin with an slash (representing the root dir of the war file or the root dir of the module if you're using modules), that is "/admin.css" if the css is in the root dir of the war.
          Hope that helps. If not, provide some more feedback.

          • 2. Re: Simple reference of CSS from JSP doesn't work
            ian.fallon

            Raist_Majere,

            Thanks for your reply. This (now solved) was a bit of a wierd one. The bit of test CSS I was using simply modified the look of <h1>. I was using Firefox to view the page and for some wierd reason Firefox seems to ignore the first CSS tag defined! So the paths issue was a red herring in the end, that was all working!

            Regards,

            Ian