- This topic has 5 replies, 2 voices, and was last updated 19 years, 9 months ago by AKunze.
-
AuthorPosts
-
AKunzeMemberHello,
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
AKunzeMemberI will specify my question. How can I work with such inlude-files, without getting an error in myeclipse?
arjan.tijmsMember@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 variableThis 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.
AKunzeMemberSorry, but changing the prefix to .jspf or using of <jsp:include page=””…> does not disapper the error-message.
arjan.tijmsMemberOf 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.
AKunzeMemberok, with
<jsp:include page=….
and
<jsp:useBean…
in the included-pagethere are no errors in my simple example.
I will now edit mey existing source code.
best regards
-
AuthorPosts