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 

6 comments:

  1. Replies
    1. Big data is a term that describes the large volume of data – both structured and unstructured – that inundates a business on a day-to-day basis. big data projects for students But it’s not the amount of data that’s important.Project Center in Chennai

      Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Corporate TRaining Spring Framework the authors explore the idea of using Java in Big Data platforms.

      Spring Training in Chennai

      The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

      Delete
  2. The article is so appealing. You should read this article before choosing the Hadoop consulting services you want to learn.

    ReplyDelete
  3. Really this is very good information. I really enjoyed it. Thank you for sharing the informatin. Keep on sharing the information.
    Python Training in chennai

    Python Course in chennai

    ReplyDelete
  4. 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