- This topic has 2 replies, 2 voices, and was last updated 17 years, 8 months ago by ellipsis.
-
AuthorPosts
-
ellipsisParticipantCan 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”>
<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>
——————————————————————————–
Scott AndersonParticipantellipsis,
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.
ellipsisParticipantDear Scott,
Fantastic, exactly what I was looking for! Thanks for your help.
Eric@Ellipsis
-
AuthorPosts