Skip to main content

JSonArray castexception error.

1 reply [Last post]
Joined: 2007-10-16

I get the example from blog but it error
"org.json.JSONArray cannot be cast to java.lang.String"
Please explain me. What it error because?
Error log: "org.json.JSONArray cannot be cast to java.lang.String"

Jsp Code:

Java Code:

public class AppllicationBean {
private String country;
//Then you create your properties to get and set the data:
public String getCountry () {
return country;

public void setCountry(String country) { = country;

private String[] countries =
new String[] {
"Japan", "Thailand", "Uganda", "Ukraine",
"United States of America"

private String[] countryCodes =
new String[] {
"JP", "TH", "UG", "UR", "USA"
//Now, you need to use JSON to convert that data to a form JavaScript can evaluate:
public JSONArray getCountryService() {
JSONArray countriesData = new JSONArray();
JSONArray countryData = new JSONArray();
for (int loop=0; loop < countries.length; loop++){
countryData = new JSONArray();
return countriesData;


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-07-31