I'm having a problem with accessing variables using JSTL ...

First, I started web development only a few months ago.  So, my question may seem generic, but I need help.

I have a filen events.jsp with 2 forms.  The first form is an input form, the second form is a search form which pulls query results into a datagrid (I'm using displaytag for the table).  These records can be edited in the first form.  When I select a record in form 2, in my control.jsp, I pull the record from the DB, and c:redirect to events.jsp using the reults as parameters (in results, .  When I make changes to the record, my control.jsp completes the action and I c:redirect the results and msg to events.jsp from control.jsp.  

Everthing works, except I not able to use ${param.results} to take action.  I've put debug code to display the value and my results shows in events.jsp.  But, my condition (c:if) cannot see the value.  I even tried using a session scope variable declared in control.jsp, but this doesn't seem to work either.  

My c:set statements from control.jsp:
   <c:set var='results' value='Event Add Error!' scope='session' />
   <c:set var='msg' value='${errMsg}' scope='session' />

I tried to access the sessionScope variable in events.jsp by using the following with no luck, results is empty:
   <c:if test="${!empty sessionScope.results}" >
         <script language="JavaScript">
         <!--
                   //Do some things here ...
      if ("${sessionScope.results}" == "Event Add Error!"){
          validateEventForm(document.eventsEditform);
          messageWindow("${sessionScope.results}", "${sessionScope.msg}");
      }
          //-->
         </script>
   </c:if>

I also tried to access the parameter variable in events.jsp by using the same code with simple change as follows with results being empty:
   <c:if test="${!empty param.results}" >
         <script language="JavaScript">
         <!--
                   //Do some things here ...
      if ("${param.results}" == "Event Add Error!"){
          validateEventForm(document.eventsEditform);
          messageWindow("${param.results}", "${sessionScope.msg}");
      }
          //-->
         </script>
   </c:if>


Is there something I'm not understanding about using the c:set?  If I set a session variable in control.jsp, shouldn't I be able to see it in events.jsp?  Why would the param.results and param.msg be empty (but print out in my debug statements?  Do you have any suggestions?

Thanks in advance.

csaexpertsComputer SpecilaistsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

darkappleCommented:
i just can't find error for now...

check once if value is set with



in events.jsp or you can either check whether there is session variable present or not with


try once like this


       <!-- Do something here -->      
       
      




Hope this helps
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
darkappleCommented:
are you using this tag-library for core.

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
0
csaexpertsComputer SpecilaistsAuthor Commented:
I already have the <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> .  It's a different order,
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>, would that make a difference??

I also tried the c:out for param.msg, which printed the message (I see the value) and for what ever reason (?) the param annotation now works.  But the sessionScope variable is still not showing.

I'm not sure how to use the suggestion  logic:notPresent ....   Could you elaborate?

</logic:notPresent>

0
darkappleCommented:
that doesn't make differnce.



       <!-- Do something here -->      
       
     



Here i'm checking where session variable results is present or not.

The statements inside  comes into action when results variable is absent in session.

and  checks for presence of variable in session.


The equivalent of following code


   


will be like






hope this helps you


0
csaexpertsComputer SpecilaistsAuthor Commented:
The logic:present annotation was helpful, although not a complete solution.  I'm able to get around my dilemma by passing parameters from control.jsp to events.jsp.  This seems to be working now.  Thank for you help, I learned something which is always good.  MJ
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.