• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamic SelectBox  RSS feed

 
DecK DecKer
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all coders ! I'm in trouble 'cause I alwais receive this error when I'm working with this component ( it's a generator of a html select box based on a query on a single column that allows the user to select many values from it but giving also the chance to remove it if not necessary ).
Here's the error :
java.lang.ClassCastException: java.lang.String cannot be cast to [[Ljava.lang.Object;
at it.consumer.DynamicSelect.doGet(DynamicSelect.java:92)

Here's the code

Don't look at all System.out.println... just visual debug ;)
Hopin' the community can help me, I wish good work at all
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error explains itself. You are trying to cast a string object to a an array. No can do.

In your later code you set the value of the scoped variable to one of an array or a string. Apparently the latter has occurred. That's all pretty messy. And it's a really poor idea to builf HTML in strings in a servlet. Why are you using this approach?
 
DecK DecKer
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it's just an exercise. the goal of this servlet is to create only the select box... that can be used for future project
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, be aware that in the real world, generating markup in a servlet would be frowned upon.

The fact remains that you are trying to cast incorrectly. Why do you set the value of the scoped variable to a string sometimes, and an object at others? Later on, how are you supposed to know which one to cast it to?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!