KristianB
KristianB

Reputation: 1443

JSP Custom tags disables use of anything else

I'm trying to make a simple login with JSP, and I have a custom tag like this

<h:mainwrapper>

with some simple div's inside... and what i'm trying to do is to execute <%=error %> inside that custom tag.

I get the following error:

org.apache.jasper.JasperException: /login.jsp(38,8) Scripting elements ( &lt;%!, &lt;jsp:declaration, &lt;%=, &lt;jsp:expression, &lt;%, &lt;jsp:scriptlet ) are disallowed here.

Code-example:

    <h:mainwrapper>
        <h:topempty />
        <div style="margin: auto; width: 300px; height: 300px; border: 1px solid black; margin-top: 100px;">
            <div style="width: 170px; height: 250px; margin: auto; text-align: center;">

                <form action="LoginCheck" method="post">
                    <p>Login name:</p>
                    <input type="text" name="loginname" />
                    <p>Password:</p>
                    <input type="password" name="loginpass" /><br />
                    <input type="submit" name="submit" value="Login" />
                </form>

                <div style="color:#f00;">
                    <%=error %>
                </div>
            </div>

        </div>
    </h:mainwrapper>

Do I have to enable something to let this be allowed?

Upvotes: 0

Views: 2257

Answers (1)

BalusC
BalusC

Reputation: 1108742

Use EL. Assuming that error is been set as an attribute in page, request, session or application scope, then you can just do

${error}

Upvotes: 1

Related Questions