• Post Reply Bookmark Topic Watch Topic
  • New Topic

Converting a List to another type

 
Dale DeMott
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm looking to convert a List to another type. Whatever type that is, it needs to be able to be instantiated. that way I can pass it to a JSP page. Right now I can't pass the list in as a bean because the compiler complains that it can't be created. I prefer to NOT iterate through the List to create a Vector or something of the like. If there is an easier way.. that would be great!

TIA
[ January 05, 2007: Message edited by: Bear Bibeault ]
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dale DeMott:
Right now I can't pass the list in as a bean because the compiler complains that it can't be created.


That's strange. If you are trying to pass a List in, why should the compiler try to generate code for "creating" it?

Perhaps you should post your JSP code, there might a be something wrong with how you are trying to do it.
 
Dale DeMott
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code wants to be able to create an instance of it. List is an interface.. so you can't create a NEW of it. I just created an object called DataBean that took any Object. then I casted it out of the object once it got to the jsp.

When I use

<jsp:useBean id="list" class="java.util.List" scope="session" />

in the jsp, the compiler complains... but if I make it a type that is not an interface, it works fine.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand you correctly, you want to pass the list to the JSP - you actually don't need it to instantiate it itself?

Then you should use type= instead of class= - which will allow you to use a non-instantiable type.

Moving to our JSP forum...
 
Dale DeMott
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Taht's exactly what I did. Figured it out later. Thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!