• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Getting an error

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

while iam trying to run following code . I am getting an error.



<html:select property="endYear"name ="customerForm" >
<% Calendar = Calendar.getInstance();
int NUM_YEARS1 = 3; // show 3 years out
int year1 = calendar1.get(java.util.Calendar.YEAR);
for (int i = 0; i < NUM_YEARS1; i++) {
System.out.println("Year = "+year1); %>

<html ption value="<%=year1%>"><%=year1%></html ption>
<% year1++;
} %>


error:



cannot find symbol
symbol : method setValue(int)
location: class org.apache.struts.taglib.html.OptionTag
_jspx_th_html_option_54.setValue(year1);
^
1 error


Thanks
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extermely hard to read and most people will just go elsewhere. Please read this for more information.

You can go back and change your post to add code tags by clicking the .
 
Bacchi Gerem
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<html:select property="endYear"name ="customerForm" >
<% Calendar = Calendar.getInstance();
int NUM_YEARS1 = 3; // show 3 years out
int year1 = calendar1.get(java.util.Calendar.YEAR);
for (int i = 0; i < NUM_YEARS1; i++) { %>
<html ption value="<%=year1%>"><%=year1%></html ption>
<% year1++;
} %>
</html:select>


error:



cannot find symbol
symbol : method setValue(int)
location: class org.apache.struts.taglib.html.OptionTag
_jspx_th_html_option_54.setValue(year1);
^
1 error
 
Ranch Hand
Posts: 471
Mac OS X Hibernate Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Bhaskar,

Simply, the setValue method in the option tag of the html tag library takes a string, and you are giving it an integer. I suggest that you use JSTL with EL instead of scriptlets, so that you won't face type conversion problems like this.
 
I've got no option but to sell you all for scientific experiments. Or a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic