Watch out for browser caching issues with a JSP stylesheet. It may be slow
to adopt new preferences because the browser is using a cached copy. Turning
caching off might hurt the performance of both the server (having to
regenerate the stylesheet for each page view) and browser (having to
download the stylesheet for each page view).

Perhaps you could keep track of when the preferences change (e.g. save the
current time in millis as a bean attribute) and pass that on the query
string to the stylesheet JSP. The stylesheet JSP would totally ignore the
parameter, but the browser would know when it needs to get a new copy of the
stylesheet because the query string would be different.

So, if you used:

<LINK REL="stylesheet"
      TYPE="text/css"
      HREF='<%= response.encodeURL("stylesheet.jsp?u="+bean.getLastUpd())
%>'>

To the browser, the URL would be:

stylesheet.jsp?u=67463286042323 - never seen this URL before, make request
stylesheet.jsp?u=67463286042323 - use cached copy
stylesheet.jsp?u=67463286042323 - use cached copy
stylesheet.jsp?u=67463286042323 - use cached copy
stylesheet.jsp?u=75837537598378 - never seen this URL before, make request
stylesheet.jsp?u=75837537598378 - use cached copy
stylesheet.jsp?u=75837537598378 - use cached copy
stylesheet.jsp?u=75837537598378 - use cached copy
stylesheet.jsp?u=75837537598378 - use cached copy
stylesheet.jsp?u=75837537598378 - use cached copy
...

-Max

----- Original Message -----
From: "Peter Pilgrim" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, September 07, 2001 5:20 AM
Subject: Re: Personalisation Best Practice


>
> Thanks guys you given me an idea. To store perhaps the actual
personalisation
> in database table.
>
> stylesheet.jsp:
>
> <% response.setContentType("text/css"); %>
>
> h1 {
>      <bean:write name="styleBean" write="h1Style" />
> }
>
> Where I could create a table CSSDEF
>
> Element ,  Name, Defn
>
> "h1" | "red" | "color:#FF0000 ;"
> "h1" | "green" | "color:#00FF00 ; "
> "h1" | "blue" | "color:#0000FF; "
>
> select  Element , Defn from CSSDEF where Name="Red" and Element="h1"
>
> I will think about this a bit more, still fuzzy ...
>
> --
> Peter Pilgrim          |  |        ++44 (0)207-545-9923
>             .... \  \  ___   /  / ... .
>             -   ----  ( * )  ---   --
> _____________________________Cafe_Savannah,_San Antonio,Ibiza__
>
>
>
> ---------------------------------------- Message
History ----------------------------------------
>
>
> From: "Gregor Rayman" <[EMAIL PROTECTED]> on 07/09/2001 12:37 ZE2
>
> Please respond to [EMAIL PROTECTED]
>
> To:   <[EMAIL PROTECTED]>
> cc:
> Subject:  Re: Personalisation Best Practice
>
>
> "Peter Pilgrim" <[EMAIL PROTECTED]>
>
>
>
> > How do I get a  "*.css" file recognised as valid Java Server Page?
> > --
> > Peter Pilgrim          |  |        ++44 (0)207-545-9923
> >             .... \  \  ___   /  / ... .
> >             -   ----  ( * )  ---   --
> > _____________________________Cafe_Savannah,_San Antonio,Ibiza__
>
> You do not need that.
>
> You can do something like this:
>
> in your html.jsp:
>
>
> <LINK REL="stylesheet"
>       TYPE="text/css"
>       HREF='<%= response.encodeURL("stylesheet.jsp") %>'>
>
>
> and stylesheet.jsp would produce the generated stylesheet, something
> like this:
>
> stylesheet.jsp:
>
> <% response.setContentType("text/css"); %>
>
> h1 {
>   <% if (likeItRed) { %>
>     color: red;
>   <% } else { %>
>     color: blue;
>   <% } %>
> }
>
>
> (better use the <logic:*> tags)
>
> --
> gR
>
>
>
>
>
>
>
> --
>
> This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
>
>
>

Reply via email to