File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Need help to get client Watch "Need help to get client New topic
Author

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!
Leena


[SCJP2, SCWCD1.3, SCBCD]
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
Sheriff

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
Sheriff

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
Rancher

Joined: Mar 22, 2000
Posts: 12675
    
    5
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.

Bill


Java Resources at www.wbrogden.com
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:
http://people.n0i.net/altblue/colors/css-system-colors.html
[ August 27, 2007: Message edited by: dave taubler ]

Dave Taubler<br />Specializing in <a href="http://taubler.com/articles/" target="_blank" rel="nofollow">Java and Web Development</a>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

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] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help to get client's system colour
 
Similar Threads
Any jsp/html page without theme
Exclusion of themes from a jsp based on Struts
Xhtml tag
get client's system name
How to run jar file in jsp?