aspose file tools
The moose likes Servlets and the fly likes how to set header tags color using cookie? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply 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: 902
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: 860

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: 56192
    
  13

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.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 902
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: 2407
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: 902
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: 1272
    
    7

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: 902
<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: 16483
    
    2

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

Joined: Aug 20, 2011
Posts: 902
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: 16483
    
    2

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: 902
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?
 
Similar Threads
setting styles in Display tags
Cookie/Header Doubt
how to set Persistant Cookies
why i can't get cookie from a special web site?
Cookie