Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Tomcat throwing Error in jsp

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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?
 
I've read about this kind of thing at the checkout counter. That's where I met this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic