JSP - Debug


http://www.eclipse.org/webtools/jst/components/jsp/tests/jsp-breakpoint-test.html - done reading
http://docs.oracle.com/cd/E13224_01/wlw/docs103/guide/webapplications/workshopJSP/tutorialJSP/TutorialJSPDebug.html - done reading
http://stackoverflow.com/questions/123462/debug-jsp-from-eclipse - done reading
https://waynebeaton.wordpress.com/2006/07/11/debugging-jsps-using-eclipse-webtools/ - done reading
http://programmers.stackexchange.com/questions/40564/how-can-i-debug-a-jsp - done reading
http://www.jvmhost.com/articles/remotely-debug-java-jsp-eclipse - done reading
https://www.laliluna.de/articles/posts/debugging-jsp-java-tutorial.html - done reading
http://www.coderanch.com/t/104783/vc/debug-JSP-eclipse - done reading


How can we debug a JSP file on the server using Eclipse?

If you need to debug a JSP file, you are doing something wrong or somebody is doing something wrong. JSP is for presentation level stuff. Business logic should be stored in a Java file instead of a JSP file.

To debug a JSP file on a server:

  1. In the Project Explorer view, open your JSP file. In a Web project, JSP files are located in the Web Content folder. Double-click the JSP file, the file opens in an editor.
  2. To set one or more breakpoints, you can select a line of code in the editor and double-click the marker bar directly to the left of the line where you want to add the breakpoint.
  3. From the JSP file's context menu in the Project Explorer view, click Debug As> Debug on Server. The workbench switches to the Debug perspective and the server is launched in debug mode.
  4. In the Debug view, step through the code and make the necessary changes to the JSP file. For detailed information on debugging, refer to the Debugging Java™ applications documentation.
  5. Save the JSP file.
  6. Click the Refresh icon in the Web Browser to update the changes. The state of your application is not lost and the server recognizes your changes.
  1. Create a server
    1. Window > Preferences > Server > Installed Runtimes
    2. Add..
    3. choose the appropriate version of Apache Tomcat
    4. Point to your appropriate Tomcat directory
  2. Create a J2EE module
    1. File > New > Project
    2. Web > J2EE Web Module
    3. use the Tomcat server you just added as the Target server
  3. Create a JSP
    1. in the WebContent folder of your project create breakpoint-test.jsp file
  4. Add some breakpoints
    1. double click in the left hand ruler in some of the scriplet sections to add breakpoints or right click in the ruler and select "toggle breakpoints"
  5. Add the server
    1. Window > Show View > Other…
    2. Server > Servers
    3. right click (in the servers view) > New > server
    4. select the appropriate variety of Tomcat server
    5. add your J2EE module to this server
  6. Debug on server
    1. right click on the breakpoint-test.jsp file in the package explorer
    2. select "Debug on Server"
    3. the server should start, and you should be switched to the debug perspective
    4. you should be able to step through the breakpoints
    5. you should be able to reload the page to start debugging
    6. try adding/removing breakpoints, reloading the page
    7. you should be able to see/enable/disable the breakpoints in the brekpoints view

How can I evaluate an expression?

Right click on the marked expression, you want to inspect and choose Inspect or press Ctrl + Shift + I.

You can also add the expression to the Expression view.

If you want to display the type and the value of an expression, mark the expression and choose the Display option from the context menu (right mouse button) or press Ctrl + Shift + D.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License