Debug javascript inside jsp page using Chrome?

Is there a way to debug javascript that is inside the jsp page, for example using chrome:

<script> var error = "${error}"; if(error != ""){ alert(error); } </script> 

In the Developer Tools window, I can only find .js files.

+7
source share
2 answers

Put the magic word debugger , open the developer tools and reload the page to debug it. It works as a breakpoint:

 <script> var error = "${error}"; debugger if(error != ""){ alert(error); } </script> 
+13
source

You will not see the JSP file in your browser, since the JSP servers are interpreted there and eventually turn into HTML code, which is then sent to your browser. In Chrome Dev Tools, on the Sources tab, the page itself (your page layout) should be indicated in the list of sources on the left (it can be called what you called your page, or it can be called something common, for example (program) ). You can find your JavaScript code there (since the JS that you put in the JSP should have ended up being displayed on the page), and you should be able to place breakpoints in it and do something else that could be simple the .js file.

+4
source

All Articles