Well, first of all, you're not 'using if in the div tag'. It doesn't matter what you put around the scriptlet as long as the whole JSP can be translated and compiled as a valid
servlet with legal
Java code.
The text around the scriptlet could simply be plain text without HTML markup and that would also work; it follows the basic syntax of:
The template text could be absolutely anything, it doesn't matter to the scriptlet code.
Now, to your problem. You haven't specified what the problem is, yet. You only say you're unable to use if with the div tag which obviously isn't a problem as explained above. So what do you expect to happen and what actually happens?
And your code that you've posted has changed between the first and second posts which means that you're either modifying the code ( incorrectly ) or you're paraphrasing and not posting the exact code. Please, always copy-paste your original code since if you just type it out you run the risk of hiding your errors and masking mistakes.
As of now, the last code posted has this:
You're closing the <table> and <div> outside of the if block which means that these tags will always be printed. Not that it makes much difference to the page rendering ( unless you have tables/ divs above this level ) but it makes your whole code suspect. So you'll have to be clear with both, the code you're posting as well as your actual problem.