Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

debugging JSPs

Options
  • 29-01-2004 4:05pm
    #1
    Registered Users Posts: 4,222 ✭✭✭


    I'm currently using NetBeans IDE for JSP and serverlet development.
    Debugging the serverlets is fine but i'm finding debugging the jsps an absolute nightmare. one page i'm trying to debug is throwing a NullPointerException and i cant for the life of me find whats throwing it. stepping through the $jsp file takes for ever and doenst provide any really useful info at all.
    Is there any easy or even slightly easier way to debug jspa?


Comments

  • Registered Users Posts: 139 ✭✭soiaf


    Having never used NetBeans IDE, I can't speak for how it works, but heres one method that has worked for me (on iplanet web server).

    When a user calls the JSP, two files are made automatically by the server, a JAVA file and a CLASS file. Both these files are stored is a 'Classcache' directory on the server.
    If an exception gets thrown, the web server error log will have various lines talking about the exception and giving a particular line number in the JAVA file it generated from your JSP file.

    So, if your file is index.jsp, the JAVA file may be called _index_jsp.java

    So if you then open up this JAVA file, go to the appropriate line, you should be able to see pretty quickly what the problem is, and fix it then in your JSP file.

    Don't know if this is at all applicable to you, but might help....


  • Registered Users Posts: 3,886 ✭✭✭cgarvey


    yeah .. what he said, except that in TomCat its the work directory.

    .cg


  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    I use Ant to catch compile-time errors. Each time I do a full build I use the JSPC task to compile the .jsp pages into servlets.
    You could then compile them into .class files too and, with some Ant trickery, create a web.xml file with all the corresponding servlet entries and mappings. Giving you a completely binary web-app!

    I digress, usually when I get a NullPointerException that I can't find I either go looking through the generated .java servlet or test for null in the JSP:
    if (null == someObject)
    {
       System.out.println("someObject is null, find out why");
    }
    

    That'll show up on the console then if the object is null.
    There's probably better ways for debugging but that's what I do.

    HTH


Advertisement