Check if portlet object exist in JSP











up vote
0
down vote

favorite












File a.jsp has code:



<%
Object OBJECT = smt...
%>

<jsp:include page="c.jsp"/>


File c.jsp has code:



<%
do smth with OBJECT
%>


File b.jsp has code:



<jsp:include page="c.jsp"/>


Problem is that b.jsp does not have code for creating/initialize a OBJECT and when workflow is such that b.jsp is supposed to be rendered there is a "OBJECT
cannot be resolved to a variable" error.



How to check if OBJECT exists in c.jsp page context?










share|improve this question






















  • Check the answer, and let us know whether your problem is solved or not!
    – Avijit Barua
    yesterday















up vote
0
down vote

favorite












File a.jsp has code:



<%
Object OBJECT = smt...
%>

<jsp:include page="c.jsp"/>


File c.jsp has code:



<%
do smth with OBJECT
%>


File b.jsp has code:



<jsp:include page="c.jsp"/>


Problem is that b.jsp does not have code for creating/initialize a OBJECT and when workflow is such that b.jsp is supposed to be rendered there is a "OBJECT
cannot be resolved to a variable" error.



How to check if OBJECT exists in c.jsp page context?










share|improve this question






















  • Check the answer, and let us know whether your problem is solved or not!
    – Avijit Barua
    yesterday













up vote
0
down vote

favorite









up vote
0
down vote

favorite











File a.jsp has code:



<%
Object OBJECT = smt...
%>

<jsp:include page="c.jsp"/>


File c.jsp has code:



<%
do smth with OBJECT
%>


File b.jsp has code:



<jsp:include page="c.jsp"/>


Problem is that b.jsp does not have code for creating/initialize a OBJECT and when workflow is such that b.jsp is supposed to be rendered there is a "OBJECT
cannot be resolved to a variable" error.



How to check if OBJECT exists in c.jsp page context?










share|improve this question













File a.jsp has code:



<%
Object OBJECT = smt...
%>

<jsp:include page="c.jsp"/>


File c.jsp has code:



<%
do smth with OBJECT
%>


File b.jsp has code:



<jsp:include page="c.jsp"/>


Problem is that b.jsp does not have code for creating/initialize a OBJECT and when workflow is such that b.jsp is supposed to be rendered there is a "OBJECT
cannot be resolved to a variable" error.



How to check if OBJECT exists in c.jsp page context?







java jsp liferay portlet






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 2 days ago









user435421

185416




185416












  • Check the answer, and let us know whether your problem is solved or not!
    – Avijit Barua
    yesterday


















  • Check the answer, and let us know whether your problem is solved or not!
    – Avijit Barua
    yesterday
















Check the answer, and let us know whether your problem is solved or not!
– Avijit Barua
yesterday




Check the answer, and let us know whether your problem is solved or not!
– Avijit Barua
yesterday












2 Answers
2






active

oldest

votes

















up vote
0
down vote













You can use if condition in jsp like...



  <c:if test = "${object == null}">
what you want to do...
</c:if>


To use this syntax you need to add this line at the top of jsp page!



<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>


And need to add JSTL jar at lib folder. You can get it from here






share|improve this answer




























    up vote
    0
    down vote













    You can use <c:if /> taglib in Liferay. At the top section of your jsp file insert this line:



    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>


    Then you can use the taglib as follows:



    <c:if test="<%= object != null %>">
    <!-- HTML elements -->
    <%
    //scriptlet
    %>
    </c:if>





    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














       

      draft saved


      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238472%2fcheck-if-portlet-object-exist-in-jsp%23new-answer', 'question_page');
      }
      );

      Post as a guest
































      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      0
      down vote













      You can use if condition in jsp like...



        <c:if test = "${object == null}">
      what you want to do...
      </c:if>


      To use this syntax you need to add this line at the top of jsp page!



      <%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>


      And need to add JSTL jar at lib folder. You can get it from here






      share|improve this answer

























        up vote
        0
        down vote













        You can use if condition in jsp like...



          <c:if test = "${object == null}">
        what you want to do...
        </c:if>


        To use this syntax you need to add this line at the top of jsp page!



        <%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>


        And need to add JSTL jar at lib folder. You can get it from here






        share|improve this answer























          up vote
          0
          down vote










          up vote
          0
          down vote









          You can use if condition in jsp like...



            <c:if test = "${object == null}">
          what you want to do...
          </c:if>


          To use this syntax you need to add this line at the top of jsp page!



          <%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>


          And need to add JSTL jar at lib folder. You can get it from here






          share|improve this answer












          You can use if condition in jsp like...



            <c:if test = "${object == null}">
          what you want to do...
          </c:if>


          To use this syntax you need to add this line at the top of jsp page!



          <%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>


          And need to add JSTL jar at lib folder. You can get it from here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 2 days ago









          Avijit Barua

          9161215




          9161215
























              up vote
              0
              down vote













              You can use <c:if /> taglib in Liferay. At the top section of your jsp file insert this line:



              <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>


              Then you can use the taglib as follows:



              <c:if test="<%= object != null %>">
              <!-- HTML elements -->
              <%
              //scriptlet
              %>
              </c:if>





              share|improve this answer



























                up vote
                0
                down vote













                You can use <c:if /> taglib in Liferay. At the top section of your jsp file insert this line:



                <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>


                Then you can use the taglib as follows:



                <c:if test="<%= object != null %>">
                <!-- HTML elements -->
                <%
                //scriptlet
                %>
                </c:if>





                share|improve this answer

























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  You can use <c:if /> taglib in Liferay. At the top section of your jsp file insert this line:



                  <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>


                  Then you can use the taglib as follows:



                  <c:if test="<%= object != null %>">
                  <!-- HTML elements -->
                  <%
                  //scriptlet
                  %>
                  </c:if>





                  share|improve this answer














                  You can use <c:if /> taglib in Liferay. At the top section of your jsp file insert this line:



                  <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>


                  Then you can use the taglib as follows:



                  <c:if test="<%= object != null %>">
                  <!-- HTML elements -->
                  <%
                  //scriptlet
                  %>
                  </c:if>






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 2 days ago

























                  answered 2 days ago









                  Abdollah

                  4011




                  4011






























                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238472%2fcheck-if-portlet-object-exist-in-jsp%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest




















































































                      Popular posts from this blog

                      Florida Star v. B. J. F.

                      Danny Elfman

                      Lugert, Oklahoma