Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to debug jsp page when there is no line number indication

 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all
when Im getting page error from the server that tells me the problem but don�t gives me the line number?
what is the best way to debug it?
how can I add print messages or any other method to check where exactly the page got stock?
this is the error im getting :
org.apache.jasper.JasperException: Unable to compile class for JSP

Generated servlet error:
Syntax error, insert "else Statement" to complete IfStatement

Generated servlet error:
Syntax error, insert "}" to complete Block

Generated servlet error:
Syntax error on token "}", delete this token

Generated servlet error:
Syntax error, insert "}" to complete ClassBody
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you check the log files of your web container (for Tomcat, inside the logs directory)
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adding print statements to your JSP page is not going to help, because the page is syntactically incorrect, and thus won't compile.

My guess would be that you have a statement like

if (...)
...;

in your code. That doesn't work in JSP pages. You need to write something like

if (...) {
...;
}

Incorrectly set or matched braces are also a possibility.
 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.dont see any thing in the log or i dont know what do look for ..
2.i know i missing } or { .. but in page with 1500 lines this somekind of hard to check if you dont have line number
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compilers usually have a hard time giving you an accuarate line number for missing quotes anyway.
A good text editor (such as VI) will give you a way to check to see which brace matches the one you're on.

Another approach would be to start commenting out large pieces of your JSP until you can get it to compile and run.
Start by commenting the whole thing out, if need be, and then start moving the end of the comment up until it breaks again.

As a side note:
Someone, earlier in the week, was asking about scriptless JSPs and what the real benefits of them are.
These types of problems make a good case for them.
 
Rusty Smythe
Ranch Hand
Posts: 93
Mac Objective C Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Meir Yan:
org.apache.jasper.JasperException: Unable to compile class for JSP

Generated servlet error:
Syntax error, insert "else Statement" to complete IfStatement


What is happening is that you've missed a semicolon or curly bracket somewhere. Fortunately, this is easy to figure out:

Assume your page is foo.jsp

1) Locate the foo.java that has been generated. If you're running Tomcat, it is probably under the work directory in yourapp/WEB-INF/classes/com/apache/...
2) Take foo.java and load it into your editor (use something good like eclipse that does syntax checking; vi or notepad are not good choices).
3) The editor will tell you in general where the problem is. Try to solve the problem.
4) Back trace to your jsp - you'll see parts of your original code in foo.java and you can figure out from #3 where you went wrong in foo.jsp.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On another side note, if you have a JSP with 1500 lines, you should seriously reconsider your design. If for no other reason -and there are quite a few- than that you have already experienced what it does for maintenance and debugging.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic