facebook

Error in the JSP-Editor (<%@ include file=...)

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #227554 Reply

    AKunze
    Member

    Hello,

    I have a problem with the jsp-debugger and including of a jsp-file.

    I will demonstrate my problem on this simple code-example:

    a section of my main jsp-file:

    
        <jsp:useBean id="myBean2" class="de.anton.Namebean"/>
        
        <%= myBean2.getSum() %>
        <br>
        
        <c:choose>
             <c:when test="${myBean.name=='anton' ||  myBean.name=='fritz'}">
               when: ${myBean.name}
               <br>
               <%@ include file="/form/include1.jsp" %>
             </c:when>
             <c:otherwise>
               otherwise: ${myBean.name}
               <br>
               <%@ include file="/form/include2.jsp" %>
             </c:otherwise>
        </c:choose>
    

    the code of include1.jsp:

    
      <h1>Include1</h1>
    
      sum: <%= myBean2.getSum() %>
    

    This simple example works fine after compiling and runnig my webapp on tomcat.
    But in the jsp-editor of include1.jsp appears
    the error: “Cannot find symbol: symbol : variable myBean2”

    I won’t change my sourcecode.
    How can I solve my problem?

    I’m using Eclipse 3.1 m4 and myeclipse 3.8.4.

    best regards

    #227557 Reply

    AKunze
    Member

    I will specify my question. How can I work with such inlude-files, without getting an error in myeclipse?

    #227576 Reply

    arjan.tijms
    Member

    @AKunze wrote:

    I will specify my question. How can I work with such inlude-files, without getting an error in myeclipse?

    I found that the editor works much better with dynamic includes than static ones. For one reason or the other static includes always give problems. Killing is the following sequence:

    declare (scriptlet) variable
    staticly include a jsp that uses this variable

    This simple sequence is usually the recept for major mahem in the editor. If you’re in the mood for an early Christmas show I envite you to try this with a reasonably complex page.

    One thing I found that helps if you -have- to use static includes, is to use the .jspf prefix instead of .jsp. You loose some features in the editor if you do that, but atleast the editor doesn’t freak out as often. Hope this helps.

    #227577 Reply

    AKunze
    Member

    Sorry, but changing the prefix to .jspf or using of <jsp:include page=””…> does not disapper the error-message.

    #227578 Reply

    arjan.tijms
    Member

    Of course, just changing it (and doing nothing else) wouldn’t work. In the case of <jsp:include> you need to transfer the bean in question via the session, and declare it’s usage with the usebean tag in the included file.

    Renaming the prefix to .jspf usually works for me; namely, the editor than simply stops all validation in that file. You can still validate the whole composition though by right clicking the top level jsp (the one that includes all others) and choosing validate jsp from the context menu. (you should try to do that anyway, and look at what it reports).

    What could be the case in your situation is that the old error (Cannot find symbol…) might not be cleared. I’ve seen this happening quite often too. Try to manually clear errors and/or rebuild your project. Usually any stale error messages disappear after that.

    #227580 Reply

    AKunze
    Member

    ok, with
    <jsp:include page=….
    and
    <jsp:useBean…
    in the included-page

    there are no errors in my simple example.

    I will now edit mey existing source code.

    best regards

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Error in the JSP-Editor (<%@ include file=...)

You must be logged in to post in the forum log in