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(login_jsp.java:139) at   
 org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94) at   
 javax.servlet.http.HttpServlet.service(HttpServlet.java:848) at   
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) at   
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) at   
 javax.servlet.http.HttpServlet.service(HttpServlet.java:848)

From the stack trace it is clear that something is null in the code. It is at line no 139. 
C:\Users\sureshatta\AppData\Local\Temp\jetty-127.0.0.1-8888-war-_-any-\jsp\org\apache\jsp

That is not the line no in login.jsp  but the compiled file login_jsp.java.  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,

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

 org.apache.jsp.login_jsp._jspService(login_jsp.java:139)  

And the line no 139 in login_jsp.java 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 

14 comments:

  1. wonderful article contains lot of valuable information. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.
    This article resolved my all queries.good luck an best wishes to the team members. learn digital marketing use these following links
    Digital Marketing Course in Chennai

    ReplyDelete
  2. "Hello there, I found your blog by way of Google while
    looking for a related matter, your website came up, it appears to be like good.

    I have bookmarked it in my google bookmarks."

    휴게텔

    ReplyDelete
  3. It appears as if some of the written text on your content are running off the screen. Can someone else please comment and let me know if this is happening to them as well?

    마사지블루

    ReplyDelete
  4. Thank you for some other informative blog. Where else could I get that type of information written in such an ideal means? I have a mission that I’m just now working on, and I have been at the look out for such information. 먹튀검증 It helped me a lot. If you have time, I hope you come to my site and share your opinions. Have a nice day.


    ReplyDelete
  5. UVK Ultra Virus Killer 11.7.0.0 Crack allows users to easily remove all kinds of malware, and perform all tasks related to Windows PC optimization, maintenance, .Pc Virus Killer

    ReplyDelete