Is there a way to debug javascript which is inside a jsp page, like this with chrome:
<script>
var error = "${error}";
if(error != ""){
alert(error);
}
</script>
In the developer Tools Window I can only find .js files.
With WebTools installed, you can add one or more breakpoints by opening an editor on the JSP file, and double-clicking in the left-hand column. A breakpoint icon will appear as shown below.
Put magic word debugger
, open developer tools, and reload the page to debug it. It works like breakpoint:
<script>
var error = "${error}";
debugger
if(error != ""){
alert(error);
}
</script>
You aren't going to see a JSP file in your browser, as JSPs are server-side and are interpreted there and ultimately turned into HTML that is then sent to your browser. In the Chrome Dev Tools, your Sources tab should list the page itself (your page's markup in its entirety) in the sources list on the left (it may be named whatever you named your page, or it may be named something generic like (program)
). You can find your JavaScript code in there (since the JS that you put in your JSP should have ultimately been rendered to the page) and you should be able to place breakpoints in it and do anything else you could with a plain .js
file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With