Access FlowScope from JSP without JSTL

I use Spring Web Flow (v. 1.0.5), and I have a JSP page that makes an AJAX call to a stream and needs to read the XML results. This thread successfully sets up the object in FlowScope and then calls up the JSP page to display the results. On a JSP page, I would like to check if an object has a property (say .firstName), and if so, do something. I can access the variable in FlowScope using the JSTL expression language (saying $ {userObj}), but that just lets me spit it out. I tried the methods below to figure this out and use the logic around this with varying degrees of success.

Update: The question remains: how to get the context and flow area in the script section (<%%>)?

<rootnode>

<!--  Attempt 1:  c:if isn't being interpreted (though ${userObj.firstName} is),
      it just displaying the tags on the page. -->
<!--  Update, I didn't have the <%@ taglib directive for jstl/core.  
      Now I do, and they're being interpreted, but it says 
         "According to TLD or attribute directive in tag file,
          attribute test does not accept any expressions"
      How can the if/@test not accept expressions?  Isn't that its whole purpose
      in life? -->
<!--  Update 2, I also forgot the taglib for the rt language, which is separate,
      I guess (jstl/core_rt).  <c:if test now works properly. -->
<c:if test="${!empty(userObj.firstName)}">
<test>not empty</test>
</c:if>

<%
/* Attempt 2:  This throws an error, can't resolve "context".  How do I get the context? */
if (context.getFlowScope().userObj != null) {
    out.write("not null");
} else {
    out.write("not not null");
}
%>

<!--  Attempt 3:  This works, I get the reference to the Object and it
      spits out the correct firstName, gives me no control other than
      spitting out the value. -->
<userReference>${userObj}</userReference>
<userReference_firstName>${userObj.firstName}</userReference_firstName>

</rootnode>
+3
1

1 , JSTL taglib web.xml Servlet 2.4. . :

, , :

<c:if test="${not empty userObj.firstName}">

<c:if test="${userObj.firstName != null}">

2 . - , , JSTL EL ( 1). , Java- (), .

3 , Javabean-to-XML, XStream. , Javabeans .

+2

Source: https://habr.com/ru/post/1740182/


All Articles