jQuery in Action, 2nd edition*
The moose likes Servlets and the fly likes how to set header tags color using cookie? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to set header tags color using cookie?" Watch "how to set header tags color using cookie?" New topic
Author

how to set header tags color using cookie?

Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 998
    
    2
can anyone tell me how can i change color of header tags (ie. h1, h2, h3), i mean accept color from user and maintain that color in cookies and use maintained color from cookie, and set color to header tag..??
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

Why would you not keep the colors in session, or a backing bean, then render the html or css from them?

at.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

I suspect that the OP means for these settings to be kept across sessions.

Seems pretty simple to me. Save the settings in a cookie; look up the cookie; format the CSS as appropriate to the settings.

Let us know when you've got it implemented and any problems you might be having with it.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 998
    
    2
i m doing it like this:


but how will i set this color as my header tags color although it's a string..??
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
You're setting the cookie for the response - you can't possibly see it in the request that happened before you created the cookie. On the second access to the servlet you should see the cookie.
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 998
    
    2
but i am able to see the cookie..
i am getting output as the color name.
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2342
    
  28

Now that you know how to get the color from the cookie, next thing you need find out how do you set the color of the header tag. Then worry about putting the color from cookie into the color of header tag.
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 998
    
    2
<h1 color="red"></h1>
this red values i m getting from user, but how do i set??
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

How are you generating that tag now?
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 998
    
    2
no but my question is, the values which i am getting from user is string, how do i set that as color??
here is i tried:
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Really, this is just beginner Java. Instead of

which just prints out a String literal, you use some code which does String concatenation to produce the desired result:

Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 998
    
    2
upps silly mistake i am sorry..
done...
thank you..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to set header tags color using cookie?