facebook

[Closed] JSP validation error on include directive

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

    ellipsis
    Participant

    Can anyone help me with this validation error:

    I have two jsp files, first one test1.jsp with a useBean declaration of the variable ‘test’, does an include directive with a second file test2.jsp where this variable ‘testVariable’ is used that was declared in test1.jsp.
    The compiler gives: ‘testVariable’ cannot be resolved. Running the jsp with tomcat gives no problem at all. What can be wrong?

    the files are
    ——————————————————————————-
    test1.jsp
    ——————————————————————————–
    <jsp:useBean class=”java.lang.String” id=”testVariable” scope=”request” />

    <!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”&gt;
    <html>
    <head>
    <meta http-equiv=”Content-Type” content=”text/html; charset=ISO-8859-1″>
    <title>Insert title here</title>
    </head>
    <body>
    <h2>Begin test</h2>
    <%@ include file=”test2.jsp” %>
    </body>
    </html>
    ——————————————————————————–

    ——————————————————————————–
    test2.jsp
    ——————————————————————————–
    <% testVariable = “test variable”; %>

    <h2>Hello world</h2>
    <h2><%= testVariable %></h2>
    ——————————————————————————–

    #267821 Reply

    Scott Anderson
    Participant

    ellipsis,

    The issue is that test2.jsp isn’t a full JSP page, but is only a JSP fragment. As such, it shouldn’t be validated as a full page or “false positives” like the one you reported will occur. To keep this from happening, you need to do to things: first, rename test2.jsp to test.jspf, which is the fragment extension mentioned in the spec. Second, turn off the preference at Window > Preferences > MyEclipse > Files & Editors > Validate JSP fragments. Then, use Project > Clean… > Clean selected projects to force a rebuild on your project. That should take care of the issue.

    #267873 Reply

    ellipsis
    Participant

    Dear Scott,

    Fantastic, exactly what I was looking for! Thanks for your help.

    Eric@Ellipsis

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: [Closed] JSP validation error on include directive

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