• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP Compilation Problem - Cannot Resolve Symbol

 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I cannot see the problem. Maybe I am not sober at 2:30 am.



I got compilation error: cannot resolve symbol
symbol: background
 
Pankaj Narang
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Your background variabel is define in while loop and you are using that variable outside that while loop.

Define that variable outside the while loop

Best Regards
Pankaj Narang
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried your advice. I put the variable 'background' outside the while loop. Now, I got another compilation error:

unexpected type
required: variable
found : value
out.write("\r\n }\r\n i++;\r\n if ( postBean.getParentPostID() == 0 ) \r\n {\r\n background = \"#FFCE9C\";\r\n }\r\n else \r\n {\r\n if ((i%2) != 0) \r\n {\r\n background = \"#EEEEEE\";\r\n } \r\n else \r\n {\r\n background = \"#FFFFFF\";\r\n }\r\n }\r\n%>\r\n");

The code looks like:
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since this has nothing to do with the fact that code is within a JSP, I'm moving this off to the Java in General(beginner) forum.
 
Axel Janssen
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this might work. Haven't tried:


And aren't we told to use ScriptLibs instead of coding lengthier sections of scriptlet, which are difficult to maintain.
This thread is a good example for that.

There must be some jstl tag which with accomplish the task in a better way.

Axel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic