• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

css implementation in jsp

 
Sandep Chaturvedi
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are facing a problem in using css in the JSP. Based on user preferences, styles of users can vary dynamically. These styles are stored in either database or ldap.
I have three options:
1. Have inline css in the JSP and make css section dynamic using <%=mystyle%> - results in cluttering
2. Have a static css file with large combination of styles and refer to these classes. ex: <TD class="cls<%=var%>"... in the jsp page - Results in large css download when only few styles are used.
3. Have a dynamic css file (css.jsp) where I dynamically change the style and refer like:
<style..... include="css.jsp"> - results in jsp execution on each request.
Any recommendations?

3.
3.
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would suggest using the third alternative.
 
Michael Arnett
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One other solution is use a jsp:include for the inline css and just have different css files. The included filename would be a variable or bean property which is set dynamically. A similar alternative is to have the external style sheet defined dynamically, eg the filename is a bean property, and there are multiple css files which are defined in the external css section of the jsp file.
Hope this helps...
-MLA
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Michael Arnett:
One other solution is use a jsp:include for the inline css and just have different css files. The included filename would be a variable or bean property which is set dynamically. A similar alternative is to have the external style sheet defined dynamically, eg the filename is a bean property, and there are multiple css files which are defined in the external css section of the jsp file.
Hope this helps...
-MLA

That was option 2, I believe.
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by James Carman:

That was option 2, I believe.

Nevermind, misread. Sorry.
 
Sandep Chaturvedi
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys, I personally would like to use jsp:include or a cc.jsp as stylesheet. Lets see what we end up with.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic