This discussion is archived
8 Replies Latest reply: Aug 2, 2012 8:18 AM by gimbal2 RSS

Debug JSP file

800839 Newbie
Currently Being Moderated
Hi,

Is there any tool to debug the JSP files? I want to debug my JSP how to do it? Please clarify.

Thanks.
  • 1. Re: Debug JSP file
    gimbal2 Guru
    Currently Being Moderated
    You shouldn't need to be overriding JSP methods, you shouldn't be writing java code in a JSP, you shouldn't have a need to debug them.

    The clean way to develop using JSPs is to use them to render a view only, using nothing but JSTL and perhaps some custom tags (never needed custom tags myself). Any business logic you have should go in a servlet, and a servlet is just a Java class so that is easy to debug. When the Servlet is done doing its things (such as fetching data from a database that needs to be displayed on a webpage), you forward control to the JSP that will represent the view, take the data fetched by or generated by the servlet and displays it using the easy JSTL tags.
  • 2. Re: Debug JSP file
    800839 Newbie
    Currently Being Moderated
    Thanks gimbal. I know what you have mentioned, for some reason i need to figure out which JSTL or Struts tags are having a problem as I am not properly defined the values in the tag which is not captured by the IDE as well. Another scenario is like I need to find the size of the list which is passed to the JSP from servlets, instead of using the JSTL tags or using out.println can i use a debugger to find it? Please clarify.
  • 3. Re: Debug JSP file
    gimbal2 Guru
    Currently Being Moderated
    797836 wrote:
    Thanks gimbal. I know what you have mentioned, for some reason i need to figure out which JSTL or Struts tags are having a problem as I am not properly defined the values in the tag which is not captured by the IDE as well. Another scenario is like I need to find the size of the list which is passed to the JSP from servlets, instead of using the JSTL tags or using out.println can i use a debugger to find it? Please clarify.
    So debug the servlet and see what is happening there. Find the problem at the root.
  • 4. Re: Debug JSP file
    ramp Explorer
    Currently Being Moderated
    gimbal2 wrote:
    You shouldn't need to be overriding JSP methods, you shouldn't be writing java code in a JSP, you shouldn't have a need to debug them.

    The clean way to develop using JSPs is to use them to render a view only, using nothing but JSTL and perhaps some custom tags (never needed custom tags myself). Any business logic you have should go in a servlet, and a servlet is just a Java class so that is easy to debug. When the Servlet is done doing its things (such as fetching data from a database that needs to be displayed on a webpage), you forward control to the JSP that will represent the view, take the data fetched by or generated by the servlet and displays it using the easy JSTL tags.
    The best answer :)
    But then there are millions of already written jsps out there already and to debug those, I use MyEclipse. It needs a paid license though.

    ram.
  • 5. Re: Debug JSP file
    ramp Explorer
    Currently Being Moderated
    gimbal2 wrote:
    You shouldn't need to be overriding JSP methods, you shouldn't be writing java code in a JSP, you shouldn't have a need to debug them.

    The clean way to develop using JSPs is to use them to render a view only, using nothing but JSTL and perhaps some custom tags (never needed custom tags myself). Any business logic you have should go in a servlet, and a servlet is just a Java class so that is easy to debug. When the Servlet is done doing its things (such as fetching data from a database that needs to be displayed on a webpage), you forward control to the JSP that will represent the view, take the data fetched by or generated by the servlet and displays it using the easy JSTL tags.
    The best answer :)
    But then there are millions of already written jsps out there already and to debug those, I use MyEclipse. It needs a paid license though.

    ram.
  • 6. Re: Debug JSP file
    gimbal2 Guru
    Currently Being Moderated
    ramp wrote:
    But then there are millions of already written jsps out there already and to debug those, I use MyEclipse. It needs a paid license though.
    A license that needs to be renewed yearly, right?

    I wouldn't pay for a tool just to be able to debug JSPs though ;) I'll just work with System.out or a logger to trace where stuff goes wrong.
  • 7. Re: Debug JSP file
    ramp Explorer
    Currently Being Moderated
    gimbal2 wrote:
    ramp wrote:
    But then there are millions of already written jsps out there already and to debug those, I use MyEclipse. It needs a paid license though.
    A license that needs to be renewed yearly, right?
    Yes, 30$ or thereabouts. I do not have to pay for it though ;)
    I wouldn't pay for a tool just to be able to debug JSPs though ;) I'll just work with System.out or a logger to trace where stuff goes wrong.
    We used to do that before we convinced the management that we work for that it really saves huge time (money and productivity)
    Its a life saver for us :). The jsps are sometimes 500 lines long (no dont kill me, I did not write those. Just have to maintain them :( ) and I shudder to think of those dark days where we kept adding incremental sysouts, then do a build and watch the stack trace. Sometimes the server did not pick up the jsp changes and a restart was needed ( more shudder :) )

    ram.

    Edit: Just wanted to add that it needs some setup and is not for the faint hearted
  • 8. Re: Debug JSP file
    gimbal2 Guru
    Currently Being Moderated
    ramp wrote:
    Its a life saver for us :). The jsps are sometimes 500 lines long (no dont kill me, I did not write those. Just have to maintain them :(
    Damn dude, there must be a less maddening job out there.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points