Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I just performed this change and it displays what you need:</p> <pre><code> protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); request.setAttribute("todo", "10"); request.getRequestDispatcher("/index.jsp").forward(request, response); } </code></pre> <p>This is the generated index.jsp:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt; &lt;title&gt;Insert title here&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;%=(String)request.getAttribute("todo")%&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>There might be something wrong with your getTodo().. I don't know how it works but maybe this could help:</p> <pre><code>... XmlMerge xmlMerge = new XmlMerge(); String todo = xmlMerge.getTodo(); ... request.setAttribute("todo", todo); </code></pre> <p>UPDATE:</p> <pre><code>PrintWriter out = response.getWriter(); out.println(...); out.close(); </code></pre> <p>This is your problem... you are getting the resource and close it. This might cause an illegal state exception issue..</p> <p>You "don't need" the dispatcher to the index.jsp.. if you don't use a dispatcher but you want to render your page you can use something like this:</p> <pre><code> protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); response.getWriter().write("&lt;html&gt;&lt;body&gt;"+getSomething()+"&lt;/body&gt;&lt;/html&gt;"); } </code></pre> <p>Why isn't index.jsp a default call? because there might not even exists an index.jsp file and it may be the call for another servlet. You can have a configuration that maps the call to index.jsp to a servlet.</p> <p><a href="http://tutorials.jenkov.com/java-servlets/web-xml.html" rel="noreferrer">http://tutorials.jenkov.com/java-servlets/web-xml.html</a></p> <p>I still don't know what is the purpose of using out.println but if you wanted it to be displayed in the jsp you can send it as argument as the "todo":</p> <pre><code> request.setAttribute("mergeFiles", mergeFiles); </code></pre> <p>And then print it in the jsp as the "todo".</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. This table or related slice is empty.
    1. 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