This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes JSP and the fly likes css implementation in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "css implementation in jsp" Watch "css implementation in jsp" New topic
Author

css implementation in jsp

Sandep Chaturvedi
Ranch Hand

Joined: Aug 20, 2002
Posts: 49
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

Joined: Feb 20, 2001
Posts: 580
I would suggest using the third alternative.


James Carman, President<br />Carman Consulting, Inc.
Michael Arnett
Ranch Hand

Joined: Mar 22, 2001
Posts: 65
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


Sun Certified Programmer for the Java 2 Platform 1.4
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
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

Joined: Feb 20, 2001
Posts: 580
Originally posted by James Carman:

That was option 2, I believe.

Nevermind, misread. Sorry.
Sandep Chaturvedi
Ranch Hand

Joined: Aug 20, 2002
Posts: 49
Thanks guys, I personally would like to use jsp:include or a cc.jsp as stylesheet. Lets see what we end up with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: css implementation in jsp
 
Similar Threads
Using CSS styles
one jsp design question
Customize Look & Feel like my.yahoo ?
Relative file paths in JSP
CSS ????