Reputation: 3757
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.
Upvotes: 18
Views: 35854
Reputation: 193261
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>
Upvotes: 26
Reputation: 7952
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.
Upvotes: 6