Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting an error

 
Bacchi Gerem
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Alaa Nassef
Ranch Hand
Posts: 471
Hibernate Mac OS X Spring
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic