How to debug gsp page? (no grail, just gsp)

I tried with netbeans and eclipse, no luck ... (don't try the IntelliJ idea)

I quickly looked at ant code

http://kickjava.com/src/groovy/servlet/TemplateServlet.java.htm

and it seems that the .gsp pages are translated into .groovy servlets (groovlets) in memory (I might be wrong) ...

so it may not be that easy to debug gsp, although I ...

so can anyone tell me how to do this?

pd: for debugging, I mean things like looking at the code step by step, checking variables, adding hours, and all that, obviously. Not the (good old) printf approach ...

+4
source share
3 answers

Most of your GSP's logic needs to be encapsulated in TagLibs, and you can debug them (at least IntelliJ) as easily as any other Groovy code.

If you have a lot of script code in your GSP (which you don't need) and you want to debug it, you cannot do much more than println . Another option is to view the source of the Groovy code generated for your GSP. This can be done by adding the showSource parameter to the URL, as described here .

+6
source

I use hack: add a method to any controller, for example static def debugme(def param) { def a = param } , and call it from gsp code: <% ThisController.debugme(this) %> or <% ThisController.debugme(params) %>

(you know that you do not need to restart the application after editing the controller or viewing it, right?)

I also don’t think that all logic should be in taglibs: page-specific logic should be clearly visible in the controller or in the view. We have most of the logic in controllers or domain classes.

+3
source

Add the parameter to Config.groovy, and the generated gsp files will be written to the directory: grails.views.gsp.keepgenerateddir = '/ some / existing / directory' (the target directory must exist and be writable)

Additional information: http://jira.codehaus.org/browse/GRAILS-4422

It should be possible to debug generated groovy code with a standard Java debugger. That was a long time ago when I did this (when I created the patch for grails), and I think I used jswat ( http://code.google.com/p/jswat/ ) to debug gsps. I could not get eclipse to find the source files, but it probably works in the Spring Tool Suite Eclipse now. You must debug the groovy code step-by-step / step-by-step and use filters, otherwise you may lose the step point (due to closing?). This is another story ...

+2
source

All Articles