JSP debugging

I've seen a lot of people asking how to debug JSP's with different application servers. We are in the process of testing the approach I'm about to outline, but we don't have it working as yet. Our application server is Weblogic, but the approach should be similar for other app servers.

Our approach is to precompile the JSP files into class files, adding the java files generated by the precompile to our project and using these generated files when setting JSP breakpoints. Our thinking is after the compilation process, JSP files are just java classes and the remote debugging features of IDEA can be used to debug these files. If we get it working, I'll post details on exactly what we had to do with Weblogic that others can use as a guide for their particular application server.

I know it's thin on details right now, but I thought I'd post it because of all the requests asking for help with JSP debugging.

0
7 comments

Well, one particular issue here is that many decent appservers won't splatter the generated files with the mapping from the source jsp page. It is this that is required to be able to set breakpoints within a jsp page (IDEA needs to be able to ask 'where should I ACTUALLY set the breakpoint, if it's set at jsp source line XXX')?

I haven't looked at the openAPI sufficiently yet, but I'm assuming that it's possible to end up with a call something like this:

User sets breakpoint in jsp
Plugin is notified of breakpoint info (page/line)
plugin does whatever magic it needs to do to get at the actual class/line, and either returns that for IDEA to set the breakpoint at, or sets a breakpoint there itself

Am I vaguely on the right lines?

0
Avatar
Permanently deleted user

We are not setting breakpoints in the JSP file. We are setting breakpoints in the generated .java file. I know this is not ideal; it's simply a workaround until a future version of IDEA supports native JSP debugging with Weblogic or a plugin is available.

Grant

0
Avatar
Permanently deleted user

of course you can set breakpoints in the generated java files, if you know where the appserver puts them and add that location to your projects sourcepath. You can do that anytime with any debugger. But that is not what (JSP) source level debugging is about.

In fact, JSP source level debugging should not be all that important, since we are all trying to avoid scriptlets by all means, aren't we?! OTOH, IDEA makes writing them so much more convenient...

0

Well, except that it gives you other niceties, like setting breakpoints in taglib calls etc. I suppose you could set them in the java source, but if you have a tag used multiple times on a page, and you want a breakpoint on the 10th occurence, it's easier to set it on the page rather than set a conditional breakpoint. Somewhat convoluted example but you get the poinbt ;)

0
Avatar
Permanently deleted user

I certainly agree with all the points you guys make. My preference would always be to set breakpoints in the JSP file itself and not the generated java file, but that simply isn't possible in the current release with Weblogic. I personally don't find it that hard to deal with the generated java file, but we take great care to keep our JSP files simple and free of programming logic. My goal was to post an alternative that would allow people to debug code that would otherwise not be possible without a plug-in.

Grant

0
Avatar
Permanently deleted user

Did you ever get this method to work? I'm using JRun4 and tried to debug
JSPs this way but I can't figure out how to get JRun to compile the Java
files created from the JSPs with debug info turned on.

"Grant Lewis" <jiveadmin@intellij.net> wrote in message
news:389111.1039096519154.JavaMail.jrun@is.intellij.net...

I certainly agree with all the points you guys make. My preference would

always be to set breakpoints in the JSP file itself and not the generated
java file, but that simply isn't possible in the current release with
Weblogic. I personally don't find it that hard to deal with the generated
java file, but we take great care to keep our JSP files simple and free of
programming logic. My goal was to post an alternative that would allow
people to debug code that would otherwise not be possible without a plug-in.
>

Grant



0
Avatar
Permanently deleted user

I did. No problem with weblogic. We precompile the JSP's with an ant target that also copies the generated source files into a jsp_servlet directory under our main source tree. The jsp source directory is added to the source path in the project properties and that's it. Use the remote debugging features of Intellij and set your breakpoint at the start of the _jspService method in the java file associated with the JSP you want to debug. I included my ant target for reference

        
            
            
            
            
            
            
            
                
            
        

        
            
                
            
        
    
]]>

0

Please sign in to leave a comment.