Search code examples
javascripthtmlcssscriptlet

CSS tags in scriptlets


I need to set an ID because I want to separate code form style. This is the code:

        <table class="form">
            <tr>
                <td class="InitialPadding">
                    <% if (message.equals("DATABASE ALREADY EXIST")){
                        out.print("<font color='red'>"+message);
                    }
                    else{
                        out.print("<font color='green'>"+message);
                    }

                    %>
                </td>
            </tr>
        </table>

The CSS that contanins the color is inside a css file, here is the hierarchy:

--Web Pages
     -css
         global.css //THIS IS THE CSS FILE
     -images
         background.jpg

     -index.html
     -install.html  //THIS IS WHERE THE SCRIPTLET IS
--Source Packages
--etc

How I can set an use an ID inside the out print, something like this:

  out.print("<id="error">"+message);

instead of:

out.print("<font color='red'>"+message);

Thanks.


Solution

    1. Give the element a type.
    2. Don't use double quotes in a variable delimited by double quotes

    Such:

    out.print("<p id='error'>" + message);