aspose file tools*
The moose likes JSP and the fly likes How to debug jsp page when there is no line number indication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to debug jsp page when there is no line number indication" Watch "How to debug jsp page when there is no line number indication" New topic
Author

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

Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

Did you check the log files of your web container (for Tomcat, inside the logs directory)


[My Blog]
All roads lead to JavaRanch
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
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.


Ping & DNS - my free Android networking tools app
Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
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

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Rusty Smythe
Ranch Hand

Joined: Aug 09, 2006
Posts: 93

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
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
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.
 
wood burning stoves
 
subject: How to debug jsp page when there is no line number indication