2

I am able to set breakpoints and debug JSP files in eclipse (see this post Debug JSP from eclipse)

The problem is I don't know how to attach the JSP source files so that I can see where debugger is stepping.

I have tried the following things with no success:

  • add the maven project as source to the debug configuration
  • Add the dynamic project nature to the project
  • zip all jsps in a jar (like regular java sources)

I don't know what eclipse is really expecting as artifact containing the JSP source files.

PS: I use Weblogic 10 and maven.

Community
  • 1
  • 1

2 Answers2

0

Put a debug point on jsp page, start server in debug mode. When the debug point is hit, you can examine the variables. You need to manually open the jsp page to see what is the exact code. But that is good enough for me.

Feng Zhang
  • 1,698
  • 1
  • 17
  • 20
-3

And you shouldn't. You must not have java code within JSP files. They are only for rendering the view, so no processing there. Do that in a servlet. See this extensive answer for why and how to do that.

Technically, you can attach the sources generated by your servlet container (in tomcat they are generated in the work directory), but you'd better fix things and move the logic to servlets and debug it there.

Community
  • 1
  • 1
Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
  • I don't have java code, mostly taglibs accessing a bunch of beans and properties. And I agree Stepping through the generated servlet can be a nightmare. The problems I ussually have are missing properties in a bean, or a null reference. A lot of people are involded in my project, so this happens more often than I'd like and the generated exception is not very helpful (line number of the impacted generated java file). If I could get a clean error or see where JSP fails I'd know a lot faster which component or property is causing problems and fix the issue a lot sooner. – Guillermo Moscoso Apr 07 '11 at 16:36
  • then debug the taglibs and beans? – Bozho Apr 07 '11 at 16:44
  • 4
    why are you giving someone hard time on asking a question! so what if he puts java code in jsp that's his problem! if you have an answer just provide that and don't make all of us read your silly irrelevant comments! – Assafn Jul 01 '11 at 09:09
  • 4
    I agree with Assafn. If you've ever worked on an old project or one that's had dozens of other developers, you've had to deal with Java in JSPs. "Don't do it" or "refactor 1000s of lines of code" is a useless answer. – Scott D. Strader Apr 05 '12 at 19:46
  • I gave an alternative approach (attaching the generated sources), though I've never done it myself. – Bozho Apr 05 '12 at 19:53
  • @Bozho In my case I don't have the source code for the taglibs, so I cannot debug them. – Guillermo Moscoso Feb 13 '13 at 20:07
  • A real life example: We have an issue in production it should be fixed quick, within a certain time limit, because of SLA. Refactoring the code is not always an option. – Paolo Mar 19 '14 at 09:44
  • One practical problem with Java is -- unlike pretty much every other web server platform -- the JVM hasn't figured how to non-disruptively hotswap servlet classes. So, if you want to be able change presentation code quickly, JSP is sometimes the best choice. It can be recompiled on the fly. Granted, you probably don't want to ever put business logic in a jsp. :-) – Kevin Seifert Feb 21 '17 at 21:52