Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Don't use <em>scriptlets</em> (those <code>&lt;% %&gt;</code> things). JSP is a template technology for HTML. You don't need all those nasty <code>out.println()</code> things for HTML. Just write HTML plain in JSP. </p> <p>So, instead of</p> <pre><code>&lt;% out.println("&lt;html&gt;&lt;title&gt;Inventory Item&lt;/title&gt;"); %&gt; </code></pre> <p>just do</p> <pre><code>&lt;html&gt;&lt;title&gt;Inventory Item&lt;/title&gt; </code></pre> <p><em>(note that this results in invalid HTML, there should be only one <code>&lt;html&gt;</code> tag in a HTML page and only one <code>&lt;title&gt;</code> in the <code>&lt;head&gt;</code>, but that's a different problem, the <a href="http://validator.w3.org/" rel="nofollow noreferrer">w3 HTML validator</a> should give a lot of hints and answers, also get yourself through some HTML tutorials)</em></p> <hr> <p>JSP offers <a href="https://stackoverflow.com/tags/el/info">EL</a> (Expression Language, those <code>${ }</code> things) to access backend data, i.e. the data which is present as attribute in <code>page</code>, <code>request</code>, <code>session</code> and <code>application</code> scopes. It can be accessed using the attribute name.</p> <p>So, instead of</p> <pre><code>&lt;% Item item = (Item) request.getAttribute("invenItem"); %&gt; </code></pre> <p>use</p> <pre><code>${invenItem} </code></pre> <p>and instead of</p> <pre><code>&lt;% out.println("Stock ID : " + item.getStockID() + "&lt;br/&gt;"); %&gt; </code></pre> <p>use</p> <pre><code>Stock ID: ${invenItem.stockID}&lt;br/&gt; </code></pre> <hr> <p>JSP also offers taglibs like <a href="https://stackoverflow.com/tags/jstl/info">JSTL</a> to control the page flow and output. </p> <p>So, instead of </p> <pre><code>&lt;% if (item != null) { } else { } %&gt; </code></pre> <p>use</p> <pre><code>&lt;c:choose&gt; &lt;c:when test="${invenItem != null}"&gt; &lt;/c:when&gt; &lt;c:otherwise&gt; &lt;/c:otherwise&gt; &lt;/c:choose&gt; </code></pre> <hr> <p>JSP also offers <code>&lt;jsp:include&gt;</code> tag to include page fragments.</p> <p>So, instead of</p> <pre><code>&lt;% RequestDispatcher rd = request.getRequestDispatcher("DataForm.html"); //NOT WORKING rd.include(request, response); %&gt; </code></pre> <p>use</p> <pre><code>&lt;jsp:include page="/WEB-INF/DataForm.jsp" /&gt; </code></pre> <p><em>(and rename it to <code>.jsp</code>)</em></p> <p>And the exception will disappear.</p> <hr> <h3>See also:</h3> <ul> <li><a href="https://stackoverflow.com/tags/jsp/info">JSP tag info page</a></li> <li><a href="https://stackoverflow.com/questions/3177733/how-to-avoid-java-code-in-jsp-files">How to avoid Java code in JSP files?</a></li> <li><a href="https://stackoverflow.com/questions/1958808/java-web-development-what-skills-do-i-need">Java web development, what skills do I need?</a></li> </ul> <hr> <p>Unrelated to the concrete problem, almost all of the links in this answer was already (in)directly given to you in your previous questions. Take them serious. To become a great programmer (as you ever stated in a question/comment), take some time to get yourself through those links (and the links in the links).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload