Capture the value of JSP Expression Language variable into a java variable

is it possible to capture the value of JSP Expression Language variable into a java variable in a jsp page?

Eg: I have a variable ${error.type} and i want to capture the value of ${error.type} into a java variable, say something like this: String errortype = ${error.type} (I know this isn't possible) Is there anyway for doing this? Actually I want to check if ${error.type} is null or not, if there is any value available I will show success message else an error message. Thanks I'm new to java and JSP :)


Update: I tried this code

 <c:choose>
     <c:when test="${not empty error.type}"> 
        test error message    
     </c:when>     
     <c:when test="${empty error.type}">
         test success message     
     </c:when> 
 </c:choose> 

But now both the text are displayed simultaneously irrespective of empty or not! Even i tried ${errors.errors ? "some text when true" : "some text when false"} and guess what, every time i'm getting "some text when false" printed in browser though the value is getting initialized correctly. any idea why?

Answers


Actually I want to check if ${error.type} is null or not, if there is any value available I will show success message else an error message

You're looking for ${empty error.type} in order to know if error.getType() is null:

<c:choose>
    <c:when test="${not empty error.type}">
        ${error.message}
    </c:when>
    <c:when test="${empty error.type}">
        <!-- show your valid message -->
    </c:when>
</c:choose>

Need Your Help

Pointers and Linked List in C

c pointers singly-linked-list

I starting study pointers and linked list in C but i have a problem:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.