Monday, August 4, 2014

How to debug JSP with help of compiled Java files in Eclipse

When I'm trying to access my jsp page, some of my code causing the problem and  it ran into some exception :P. But I know there is something wrong and want to resolve the issue and I'm not sure on how to debug a jsp file in eclipse while it is executing. I'm seeing the exception after the execution and only clue is this stacktrace. So this is the exception i'm facing.

HTTP ERROR 500 Problem accessing/index.jsp.

 Reason: Server Error Caused by: java.lang.NullPointerException at   
 org.apache.jsp.login_jsp._jspService( at   
 org.apache.jasper.runtime.HttpJspBase.service( at   
 javax.servlet.http.HttpServlet.service( at   
 org.apache.jasper.servlet.JspServletWrapper.service( at org.apache.jasper.servlet.JspServlet.serviceJspFile( at   
 org.apache.jasper.servlet.JspServlet.service( at   

From the stack trace it is clear that something is null in the code. It is at line no 139. 

That is not the line no in login.jsp  but the compiled file  As we all know, JSP converted to Java and then executes. The line numbers showing in the stacktrace are from that compiled java file. Cool , the question now is where is that compiled file stored to see the cause of error ?

Finally I found the place where the compiled jsp files. Here you can see the two files,

Do not touch that .class file and open the file. From the stack-trace 


And the line no 139 in is 

 parent= domain.startsWith("www.") ? domain.substring(3) : domain;

It clear that the only reason here to NullPointerException is domain.And I resolved that error. That's it. 

 How crap JSP is :-/.

Next >> Difference between final and effectively final in java 
Post a Comment