Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 160228

Summary: Undefined attribute name warning in JSP for a defined local variable
Product: [WebTools] WTP Source Editing Reporter: Steve Nicolai <snicolai>
Component: jst.jspAssignee: Nitin Dahyabhai <thatnitind>
Status: CLOSED DUPLICATE QA Contact: David Williams <david_williams>
Severity: normal    
Priority: P3    
Version: 1.5   
Target Milestone: 2.0 M2   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Steve Nicolai CLA 2006-10-09 12:26:48 EDT
Found in eclipse 3.2.1/WTP 1.5.1

For the following JSP page:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="java.util.Iterator"%>
<!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>Foo</title>
</head>
<body>
Foo index

<% 
    String REFRESH_PAGE="/foo";
    java.util.ArrayList a = new java.util.ArrayList();
    a.add("abc");
    String currentOpt = "abc";

%>

<select name="server">
<option onclick='document.form3.cluster.value="on";on_post(<%=REFRESH_PAGE%>)' value="">(Cluster)</option>
<%
	for(Iterator iter=a.iterator();iter.hasNext();) {
		String opt = (String)iter.next();
		String selected = opt.equals(currentOpt)?"SELECTED":"";
%>

<%-- Undefined Attribute Name (<%=selected%>). on the next line --%>
<option <%=selected%> onclick='document.form3.cluster.value="off";on_post(<%=REFRESH_PAGE%>)'><%=opt%></option>
<%		
	}
%>
</select>

</body>
</html>

Gives a warning on the 2nd <option line about an Undefined Attribute Name <%=selected%>  The variable in the expression is declared in the block above.  The page runs correctly in Tomcat 5.0.
Comment 1 Amy Wu CLA 2006-10-09 13:57:06 EDT
This has already been fixed in wtp 2.0 m2.  This will also be fixed in wtp 1.5.3 (see bug 159926)

*** This bug has been marked as a duplicate of 143209 ***
Comment 2 John Lanuti CLA 2007-04-03 12:07:49 EDT
Closing as fixed since M2.  Please reopen if closed in error.