<p>Does anyone know how to debug <code>JSP</code> in <strong>IntelliJ</strong> IDEA?</p>

<p>When I set breakpoint in my <code>JSP</code> files, those breakpoints never seem to take effect. The debugger never hits them. IDEA seems to think that the breakpoints are valid. I do see a red dot placed to the left of the line where I place my breakpoint.</p>

<p>I read in IntelliJ forum <a href="http://intellij.net/forums/thread.jspa;jsessionid=2B86A25AECC06A4BE3447388882AA79F?messageID=5218405&amp;#5218405" rel="noreferrer">in this post</a> that <code>JSP</code> files need to be under web-inf for debugging to work. </p>

<p>But then I also read that <code>JSP</code> files placed under web-inf won't be directly accessible by the user.</p>

<p>I am not sure who's really right. </p>

[{'answer_id': 33880, 'author': 'John Meagher', 'author_id': 3535, 'author_profile': 'https://Stackoverflow.com/users/3535', 'pm_score': 0, 'selected': False, 'text': '<p>For the second part of your question ("jsp files placed under web-inf won\'t be directly accessible by user") that is correct.  To allow users to access JSP files in the WEB-INF folder servlet and servlet-mapping entries need to be made in the web.xml file for each JSP page.  </p>\n'}, {'answer_id': 1332968, 'author': 'Pietro Polsinelli', 'author_id': 20478, 'author_profile': 'https://Stackoverflow.com/users/20478', 'pm_score': 5, 'selected': False, 'text': '<p>For JSP debugging in Intellij there are some configurations that must be in order. The fact that Intellij always allows you to add a breakpoint on a JSP line does not necessarily imply that you’ve configured JSP debugging.  In the following I refer to Intellij 8 configuration, w.r.t. previous versions you will need to do similar operations as the concepts are the same.</p>\n\n<p>In order to enable JSP debugging you must do two steps: set a web application configuration in your project and add a web application server configuration.</p>\n\n<p><em>Web application Configuration</em>: in order to have JSP debugging, you must have a “web” facet in your project structure, pointing to the correct web.xml file. Depending on the kind of web application structure you are using, the facet may be detected automatically by Intellij (go anyway to check what it has done) or you may have to add it manually. Remember in the “Java EE build settings” tab to set as anable “Create web facet exploded directory”; if you don’t want duplications, a trick is just to enable it and point to your already existing directory.</p>\n\n<p><em>(Web) Application server</em>:  Go to “edit configurations”, there you have to add to configurations an application server, not launch the web server as an application like any other. In this way Intellij will be able to intercept JSP calls. In the list of application servers, you should have the default one, Tomcat. Be sure to have a local Tomcat installation before you do this, and point to that when adding the web application server. The last trick is going to the “Deployment” tab and selecting as “Deployment source” the same facet that you configured in the previous step.</p>\n\n<p>The same configuration works if you want to use another web application server, I tested it with the latest Caucho Resin releases and debugging works fine (it didn’t with the previous Intellij and Resin combinations).</p>\n\n<p>If you don’t see Tomcat in the list of available application servers to add, check the plugins in the general Intellij settings pane: in the latest releases, more and more functionality has become “pluggable”, and even very basic functions may be disabled; this plugin is called “Tomcat integration”.</p>\n\n<p>Finally, it is surely not true that JSP files need to be under WEB-INF to be under debugging.</p>\n'}, {'answer_id': 1425616, 'author': 'Cong De Peng', 'author_id': 154237, 'author_profile': 'https://Stackoverflow.com/users/154237', 'pm_score': 3, 'selected': False, 'text': '<p>Anyway, you need to launch the Tomcat in IDEA, not from a remote Tomcat.</p>\n'}, {'answer_id': 23781314, 'author': 'ccpizza', 'author_id': 191246, 'author_profile': 'https://Stackoverflow.com/users/191246', 'pm_score': 5, 'selected': False, 'text': '<p>For remote JSP debugging (which also applies to <code>localhost</code>) you\'ll need to install the <a href="https://plugins.jetbrains.com/plugin/16893-debugger-support-for-jsp-jsr45-" rel="nofollow noreferrer">JSR45 support plugin</a>. <strong>Please note this feature is only supported in the Ultimate edition of IntelliJ, not the community edition.</strong></p>\n<ol>\n<li><p>Go to <em><strong>Preferences</strong></em> &gt; <em><strong>Plugins</strong></em>, search for the <strong>JSR45</strong> plugin, and\nenable it.</p>\n</li>\n<li><p>Create a run configuration: <em><strong>Run</strong></em> &gt; <em><strong>Run Configuration</strong></em> &gt; click the <kbd> <strong>+</strong> </kbd> button, and pick <em><strong>JSR45 Compatible Server</strong></em>, and then in the dialog that opens, select <strong>Remote</strong>, and set server host and port. Setting <em><strong>Application Server:</strong></em> <em><strong>Generic</strong></em> should work fine.</p>\n</li>\n<li><p>Make sure you set the correct port in <em><strong>Startup/Configuration</strong></em> &gt; <em><strong>Debug</strong></em>.</p>\n</li>\n<li><p>Open the module settings (<strong>F3</strong> on the project folder), and add a <strong>Web Facet</strong> under <strong>Facets</strong>, and under <strong>Web Resource Directories</strong> specify your JSP root folder.</p>\n</li>\n<li><p>Click the <kbd><strong>Configuration...</strong></kbd> button, and select the folders with the beans, classes and libraries that your JSPs depend on.</p>\n</li>\n</ol>\n<p>Now JSP breakpoints should work, provided that you started your server with the <a href="https://stackoverflow.com/a/975342/191246">proper debug arguments</a>.</p>\n<blockquote>\n<p><sup><em>If you have a maven project with auto-import enabled then you might want to disable auto-import because every time the auto-import is triggered your library settings will be reset.</em></sup></p>\n</blockquote>\n<p>Also see:</p>\n<ul>\n<li><a href="https://www.jetbrains.com/help/idea/run-debug-configuration-jsr45-compatible-server.html" rel="nofollow noreferrer">https://www.jetbrains.com/help/idea/run-debug-configuration-jsr45-compatible-server.html</a></li>\n</ul>\n'}, {'answer_id': 35792469, 'author': 'Romeo Frenksen', 'author_id': 6017489, 'author_profile': 'https://Stackoverflow.com/users/6017489', 'pm_score': 1, 'selected': False, 'text': '<p>Please make sure, that in you tomcat\'s <em>conf/web.xml</em> <strong>suppressSmap</strong> is <strong>not</strong> enabled as support of JSR45 is required by IntelliJ\'s debugger.</p>\n\n<p>It should look like this:</p>\n\n<pre><code>&lt;init-param&gt;\n  &lt;param-name&gt;suppressSmap&lt;/param-name&gt;\n  &lt;param-value&gt;false&lt;/param-value&gt;\n&lt;/init-param&gt;\n</code></pre>\n\n<p>From <a href="https://tomcat.apache.org/tomcat-7.0-doc/jasper-howto.html" rel="nofollow">https://tomcat.apache.org/tomcat-7.0-doc/jasper-howto.html</a></p>\n\n<blockquote>\n  <p>suppressSmap - Should the generation of SMAP info for JSR45 debugging be suppressed? true or false, default false.</p>\n</blockquote>\n'}, {'answer_id': 48931123, 'author': 'naXa stands with Ukraine', 'author_id': 1429387, 'author_profile': 'https://Stackoverflow.com/users/1429387', 'pm_score': 1, 'selected': False, 'text': '<p>If you are using the Intellij debugger you can get the value of an individual attribute by putting a breakpoint inside JSP and evaluating the expression <code>this.jspContext.request.getAttribute("attributeName")</code>.</p>\n\n<p>Note that this may return a Java Object type, and you may have to cast it to the correct type. Also if you launch a remote Tomcat the IDEA won\'t hit any breakpoints, so you need to launch the Tomcat in debug mode from inside the IDEA.</p>\n'}]
['https://Stackoverflow.com/questions/33739', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']