views:

34

answers:

1

Hi,

I have set a session scope object in my session and I want to add a disabled attribute in one of my button using JSTL Ternary operator.

The getPermission is a map of privileges for the currently login user but I am not sure why I am encountering the error unterminated c:out tag in my JSP when it goes to this JSP.

<button type="button"  id="addButton" 
    <c:out value="${empty sessionScope.voUserInfo.getPermission.ADD_ITEM ? "disabled='disabled'" : ''}"/> >
    ADD
</button>

Any advise please?

+2  A: 

The first doublequote inside the value is breaking the value too early. You should use singlequotes only to denote strings in EL, not doublequotes. You should use doublequotes only to denote HTML attribute values.

<button id="add" <c:out value="${empty var ? 'disabled="disabled"' : ''}"/>>

(please don't pay attention to the Stackoverflow code syntax highlighter, it doesn't recognize taglibs/EL correctly, the above is legitimately valid)

Or, when you're on JSP 2.0 or newer, you can even just leave that c:out away as long as there's no risk for XSS (which is not the case here since you're printing a server-controlled value).

<button id="add" ${empty var ? 'disabled="disabled"' : ''}>
BalusC
Thanks BalusC... By the way, I think I have read an article before regarding Streaming Servlet, I forgot the link but I am not sure if you are that author... Great link! I learned a lot about that..
Mark Estrada
Maybe [this](http://balusc.blogspot.com/2007/07/fileservlet.html) or [this](http://balusc.blogspot.com/2009/02/fileservlet-supporting-resume-and.html)? You're welcome :)
BalusC