The moose likes JSP and the fly likes Need help to get client's system colour Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Need help to get client Watch "Need help to get client New topic

Need help to get client's system colour

Leena Diwan
Ranch Hand

Joined: Jun 18, 2001
Posts: 351
Hi All!!

We are doing a POC currently wherein we need to get the System colours in the JSP file.
Example: If user has set a specific theme, we want to be able to get the theme details through API's on the JSP.
Based on these we want to apply colours to some custom display components.

All we are getting is AWT related classes. And that too is the server system colours and not the client's.

We need help in knowing if we can get this info by not using AWT? Is it feasible?

Thanks in advance!

Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Jsp's are converted to servlet and live in the container.From this you can at best get server properties ,not client properties.
If you would like to go for a complex solution then you might have to do some applet stuff to take the required information from the client system and send those to server , so that going forward server can generate views using this information.

By the way , how can you get theme properties ? Is this something set in the environment variables ?

Rahul Bhattacharjee
LinkedIn - Blog
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

The user's system colors are not sent to the server.
To see what is sent, install either the LiveHttpHeaders or the FireBug plugin for Firefox and look at the HTTP request headers.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Also, none of the visual widgets provided by AWT or Swing can be used in a JSP. For that you'd need to write either Applets or a JWS project.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
If I wanted to let clients set color schemes I would use CSS - a technology designed for exactly this kind of customization. You might have to create a CSS selection page to let the user select the scheme they want from a stock set or do something even more complicated with javascript.

Then all your web application has to remember is which CSS to link to in each user's pages - just one line in your JSP.

dave taubler
Ranch Hand

Joined: May 15, 2001
Posts: 132
I agree with the "use CSS' recommendation. CSS actually allows you to assign system colors to elements. For example, a color of "ButtonFace" causes the styled element to be colored as a standard system button's background would. So for example, if you were creating a small span that you wanted to look like a button, you might apply these styles (among others):

A list of said CSS system color names can be found here:
[ August 27, 2007: Message edited by: dave taubler ]

Dave Taubler<br />Specializing in <a href="" target="_blank" rel="nofollow">Java and Web Development</a>
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

Just be aware that support for system colors in CSS is not available in all browsers. Be sure to test on all browsers that you plan to support.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Need help to get client's system colour
It's not a secret anymore!