jboss and jsp problem for generic programming

D

david wolf

I am using jboss 4.0.2 and my JAVA_HOME environment variable is set to
the dir of jdk 5.0. However, when I tried to write following code in
the jsp, my jsp code would not compile when the page is browsed, what
is the reason?

Vector tmpv = new Vector(); //line 1
Vector<Vector> tmpv1 = new Vector(); //line 2

If I remove line 2 in my jsp file, it works. I do not understand if
there is anyother config I need to do in order for jboss to use feature
of jdk 5.0 for generic programming?

Thanks a lot,

David
 
L

Lew

david said:
I am using jboss 4.0.2 and my JAVA_HOME environment variable is set to
the dir of jdk 5.0. However, when I tried to write following code in
the jsp, my jsp code would not compile when the page is browsed, what
is the reason?

I am not familiar with JBoss, but many app servers specify the Java home in
their own config files and completely disregard $JAVA_HOME.
Vector tmpv = new Vector(); //line 1
Vector<Vector> tmpv1 = new Vector(); //line 2

Vector of vectors?? What is the base type of the "inner" vector?

The "new" type has to have compatible genericity with the variable type. You
did not provide a base type in the "new" expression.

The variable type says that each Vector element is itself a Vector, but says
nothing about the base type of that element's Vector. Are you trying to do
something similar to:
Vector said:
If I remove line 2 in my jsp file, it works. I do not understand if
there is anyother config I need to do in order for jboss to use feature
of jdk 5.0 for generic programming?

You might have to modify a JBoss configuration file.

That done, you should fix line 2 anyway:

Vector <BaseType> tmpv1 = new Vector <BaseType> ();

("BaseType" itself can be a generic class, e.g., another layer of
"Collection<T>".)

Bear in mind that Vector methods are synchronized. If this is overkill for
you, consider using java.util.ArrayList instead.

In most cases, the variable type should be the interface supertype of the
actual type.

List <BaseType> var = new ArrayList <BaseType> ();
or
List <BaseType> var = new Vector <BaseType> ();

Now you can change the implementation without breaking the code that depends
on "var".

List <BaseType> var = new TreeList <BaseType> ();

Homework: What drives the choice of one implementation over another?
Hint: Read the API Javadocs for each implementation.

- Lew
 
D

Daniel Pitts

david said:
I am using jboss 4.0.2 and my JAVA_HOME environment variable is set to
the dir of jdk 5.0. However, when I tried to write following code in
the jsp, my jsp code would not compile when the page is browsed, what
is the reason?

Vector tmpv = new Vector(); //line 1
Vector<Vector> tmpv1 = new Vector(); //line 2

If I remove line 2 in my jsp file, it works. I do not understand if
there is anyother config I need to do in order for jboss to use feature
of jdk 5.0 for generic programming?

Thanks a lot,

David

I would avoid using scriptlets at all, if possible. I'd look into using
some sort of MVC architecture where your controller is in Java code,
and your view is jsp. The problem could very well be that JBoss uses a
language level < 1.5 to compile JSP's.
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

david said:
I am using jboss 4.0.2 and my JAVA_HOME environment variable is set to
the dir of jdk 5.0. However, when I tried to write following code in
the jsp, my jsp code would not compile when the page is browsed, what
is the reason?

Vector tmpv = new Vector(); //line 1
Vector<Vector> tmpv1 = new Vector(); //line 2

If I remove line 2 in my jsp file, it works. I do not understand if
there is anyother config I need to do in order for jboss to use feature
of jdk 5.0 for generic programming?

JBoss (usually) uses Tomcat as web container.

Newer versions of Tomcat uses Eclipse Java compiler
not the SUN Java compiler from the JDK.

The Eclipse Java compiler in Tomcat 5.5 does not
support Java 1.5 generics.

My guess is that this is what is bothering you.

Arne
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top