css - dynamic JSP background color -


i have html form submitted jsp. form has input specifies background color preference. on jsp page, trying use background color specified user, or, if not enter anything, use color specified in css file. possible?

i have in jsp specifies location of css file, know can css background color, if user specifies color, want 'ignore' that, , use color chose.

is possible?

you load default css via <link href...>, , add overrides in <style> block on page. since styles defined on style block have precedence on other ones override default values. can see more how css "cascades" styles on w3c specs.

try in <head>

<link href="default.css" media="all" rel="stylesheet" /> <style>     /* define custom css user here */     body{         background-color: <% ... %>;     } </style> 

i suppose there many ways of producing correct output in jsp, using jstl core if tag following:

<style>     /* define custom css user here */     body{         <core:if test="${param.backgroundcolor!= null}">             background-color: <%=request.getparameter("backgroundcolor")%>         </core:if>     } </style> 

this way if user has selected custom background-color h1 element, override default.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -