The name of this question jstl_var_message
Hello and Thank you in advance for any assistance.


System info:

Netbeans, JSF, glassfish


The Purpose of this post is:

To set a variable to use to map the stylesheet.css to messages

The functionality of this code is:

In my login.jsp I have a tag that is supposed to set a var to use to format error messages.

My question is:

What do I have to do to use a var to locate the stylesheet to use for different messages?

The errors related to this code are:

I have a message telling me “According to TLD or attribute directive in tag file, attribute value does not accept any expressions”


Code description:

Please find the <c:set > tag. This is the login.jsp

<!-- login.jsp -->

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>

<!--c:remove var="subscriber" scope="session"-->

<f:view>

    <f:loadBundle var="labels" basename="view.res.Labels"/>
    <c:set var="stylesheet" value="${pageContext.request.contextPath}/stylesheet.css"/>

    <html>
        <head>
            <title><h:outputText value="#{labels.login}"/></title>
            <link rel="stylesheet.css" type="text/css" href="c:out value='${stylesheet}'/>">



        </head>
        <body>

            <h1><h:outputText value="#{labels.login}"/></h1>

            <h:outputLink value="subscribe.faces">
                <h:outputText value="#{labels.subscribe}"/>
            </h:outputLink>

            <h:form id="login">

                <h:messages globalOnly="true" styleClass="messageStyle"/>

                <p><h:outputLabel for="email"
                               value="#{labels.email}"/>
                    <h:message for="email" styleClass="message"/><br>
                    <h:inputText id="email" required="true"
                                 value="#{loginInfo.email}"
                                 size="40" maxlength="80">
                        <f:validateLength minimum="1" maximum="80"/>
                    </h:inputText>

                <p><h:outputLabel for="password"
                               value="#{labels.password}"/>
                    <h:message for="password" styleClass="message"/><br>
                    <h:inputSecret id="password" required="true"
                                   value="#{loginInfo.password}"
                                   size="10" maxlength="20">
                        <f:validateLength minimum="6" maximum="20"/>
                    </h:inputSecret>

                <p><h:commandButton id="command"
                                 value="#{labels.login}"
                                 action="#{loginInfo.loginAction}"/>

                </h:form>

        </body>
    </html>

</f:view>

Thanks again.
-ceyesumma

Note:
………………………………………………………………………………………………

Code description

> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

It seems that you are using a pre JSTL 2.0 URI; in pre 2.0 JSTL, the set action is configured to not accept run-time expressions [rtexpr=false].

Try using <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> instead; it should work.

And it did work. Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.