Thursday, 19 September 2013

Duplicates in JSP's include directive

Duplicates in JSP's include directive

This code is not real, but is simpler and show the problem
Suppose that I have First File named Base.jsp
<%!
class Base{
public String Parm0 = "";
public String Parm1 = "";
}
javax.servlet.jsp.JspWriter Out;
void PrintMessage(String Msg){
try {
Out.print("<P style=\"color:rgb(255,0,0)\">"+Msg+"</P>");
}
catch (Exception e) {}
}
%>
Now I have a Second File that use the base file: Fil0.jsp
<%@ include file="Base.jsp" %>
<%!
class File0 {
public Base MyBase;
File0 () {
MyBase = new Base();
PrintMessage("Based Used!!");
}
%>
Now I have a Third File that use the base file: Fil1.jsp
<%@ include file="Base.jsp" %>
<%@ include file="Fil0.jsp" %>
<%!
class Fil1 {
public Base MyBase;
public Fil0 MyFil0;
File0 () {
MyBase = new Base();
MyFil0 = new Fil0();
PrintMessage("Based and Fil0 Created!!");
}
%>
As you can see... this code will produce messages like:
Duplicate field Fil1_jsp.Out
Duplicate method PrintMessage(String) in type Fil1_jsp
How solve this error Before I need to include Base in two files: File0 and
File1. And File1 have Base and File0...
The compiler find two declarations...

No comments:

Post a Comment