Ensuring Type Saftey in JSTL?

H

hughes.matt

JSTL is large improvement over JSP scriptlets but one thing that I find
missing is the lack of type safety. Sometimes this can be a nice
thing...you get elements out of a map or out of an object, it doesn't
matter. But when I am working with one of my program's domain objects,
whose getter/setter methods are likely to change over time, I want to
be notified that my JSTL will break.

i.e.

I have a bean called Foo

class Foo {
String getBar() {}
void setBar(String) {}
}

In my JSP code I access a bean called fooBar1 that was stored in the
request context:

<body>
The value of bar in Foo is ${fooBar1.bar}.
</body>


Now...what happens if I changed getBar() to getBarrista(). With
today's IDE's like Eclipse, the IDE will change every method call in
your project to reflect the new name change, but JSTL has no idea it is
even dealing with the class Foo. It is just using reflection.

Is there anyway to give the JSTL a hint that I want it to check
type-saftey and name-safety when I want it to. Something like a JSP
declaration at the top of the page indicating the type

--------------------------
<%@page declareVarType scope="request" varName="fooBar1"
type="com.matt.Foo" @%>

<body>
The value of bar in Foo is ${fooBar1.bar}.
</body>
--------------------------

That way, when Jasper went to generate the JSP source code, and then
compile it, I would get a failure right there and then know I need to
change the method. Basically I want a compile-time check, not a
run-time check.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top