• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Tomcat throwing Error in jsp

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
One of my jsp has code like this
<% if()) %>
<td width="632"> Test </td>
<% else if()) %>
<td width="632"> Add </td>
<% else if()) %>
<td width="632">Delete</td>
But jsp complier always give me
Generated servlet error:
[javac] Compiling 1 source file
C:\jakarta-tomcat-4.1.12
MainMenu_jsp.java:348: 'else' without 'if'
else if()) out.write("\r\n ");
What should I do. I think this is correct code..
Any help is appreciated.
Thanks
Viku
 
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
e.g. 'if())' is NOT the right way to type a if statment... Try change ALL your code.
Rene
 
Viku John
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I am sorry code is like
<% if() %>
<td width="632"> Test </td>
<% else if() %>
<td width="632"> Add </td>
<% else if() %>
<td width="632">Delete</td>
But jsp complier always give me
Generated servlet error:
[javac] Compiling 1 source file
C:\jakarta-tomcat-4.1.12
MainMenu_jsp.java:348: 'else' without 'if'
else if()) out.write("\r\n ");
Hope now you can find some thing
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As a suggestion on debugging JSP code...

Actually look at the file that is generated. It gives you a line number... use it! C:\jakarta-tomcat-4.1.12\MainMenu_jsp.java:348

Your problem is at line 348 of the generated servlet source code.

For your specific problem, it's most likely the fact that the jsp compiler is inserting 'extra' lines, and so your simple if statements now need braces. This is just good practice anyways, and it's recommended in both Sun's and Javaranch's style guides.

sample:
<% if() { %>
<td width="632"> Test </td>
<% } else if() { %>

Oh, and I'm assuming that there is an actual condition you're testing in your if statements, right?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic