카테고리 없음

JSR-45 Debugging JSP


Spring Datafication 2022. 11. 30. 18:05

A common headache for JSP developers is debugging JSPs. The java community provides a lot of tools to debug java code. But there is no standard way to debug JSPs. The article describes how to debug JSPs in Tomcat 7.0.0 and later..
We would be using JSR-45 to debug JSPs. JSR-45 is supported by Tomcat 7.0.0 and later. JSR-45 is not supported by Tomcat 6.0.0 and earlier.
We can download JSR-000045 source

SITE

NOTICE

Only supported in the Ultimate edition of IntelliJ

JSR45 ㄧ PLUG-IN INSTALLATION

  1. Download the JSR45 plugin from the JetBrains Plugin Repository
    or from intellij plugin ui (File > Settings > Plugins > Marketplace > search JSR45)
  1. Install the plugin in IntelliJ IDEA
  2. Restart IntelliJ IDEA

CONFIGURE THE APPLICATION SERVER TO BE DEBUGGABLE

We can simply do that adding the following the application environment variables:

CATALINA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000

or we can add this to our pom.xml

 <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <jvmArguments>
                        <jvmArgument>-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005</jvmArgument>
                    </jvmArguments>

                </configuration>
            </plugin>

under the plugin configuration section.

JSR45 ㄨ CONFIGURATION

  1. Go to the application build or debug configuration menu
  2. CLick Edit Configuration

  1. Click JSR45 Compatibility Server and select Remote

  1. By default the Application server is Generic and the Server type is Tomcat. If you are using a different application server, you can select it from the drop-down list.
    or just leave it as it is.

  1. Click Apply to save the configuration.
  2. Click OK to close the configuration window.

JSR45 ㄩ DEBUGGING

When our application is running, we can debug JSPs by clicking the Debug button in the JSR45 Compatibility Server window.
Select the JSR45 Compatibility Server window and click the Debug or RUN button.

If we apply a breakpoint in a JSP, the breakpoint will be hit when we check the debugger we can see the all the variables and objects in the debugger window.

We can also see the model items we set for the view and the request and response objects.

We can observe each variable changes through the breakpoints

REFERENCES

  1. JSR-45
  2. Stackoverflow
반응형