Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to set header tags color using cookie?

 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 859
Chrome IBM DB2 Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64973
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2850
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but i am able to see the cookie..
i am getting output as the color name.
 
Jayesh A Lalwani
Rancher
Posts: 2756
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<h1 color="red"></h1>
this red values i m getting from user, but how do i set??
 
Paul Clapham
Sheriff
Posts: 21137
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you generating that tag now?
 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21137
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
upps silly mistake i am sorry..
done...
thank you..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic