Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2006

Tip: Looking for answers? Try searching our database.

jboss and jsp problem for generic programming

Thread view: 
david wolf - 13 Dec 2006 21:01 GMT
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
Lew - 14 Dec 2006 16:40 GMT
> 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 <Vector <BaseType>> tmpv1 ...?

> 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
Daniel Pitts - 14 Dec 2006 19:55 GMT
> 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
[quoted text clipped - 11 lines]
>
> 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.
Arne Vajhøj - 15 Dec 2006 02:47 GMT
> 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
[quoted text clipped - 7 lines]
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.