Domanda

I have a JSP file that @includes two other files.

The first of the included files has a global variable declared within it.

I want to use this variable in the second included file.

It works o.k. and passes compilation but eclipse says that:

*my_var* cannot be resolved to a variable

when looking at the errors under the problems tab.

is there a way to tell eclipse that this variable can be found at the first include? or do something else to stop it from showing this as an error. (preferably in such a way that if I remove the declaration from the first include I will get the error back...)

È stato utile?

Soluzione

Eclipse is not good with that, but it doesn't have to - you should not include java code in your JSPs. Instead of java variables, use request attributes and JSTL:

<c:set var="foo" value="bar" />

${foo} <!-- outputs "bar" -->
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top