request.getAttribute returning null in servlet
<p>In jsp I have written following code:</p>

<pre><code>    &lt;form action="./ssoServlet?from=amount" method="post"&gt;
    &lt;%request.setAttribute("formName", "DayCareForm"); %&gt;
    Amount  
     &lt;input type="text" name="amount" id="amount" required &gt;
     &lt;button onclick="dayCarePdf()" type="submit"&gt; Convert to PDF &lt;/button&gt;
    &lt;/form&gt;
</code></pre>

<p>Post method of servlet is:</p>

<pre><code>@Override
    public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("DoPost method");
        resp.setContentType("text/html");

        if(req.getParameter("from").equals("amount"))
        {
            req.getParameter("amount");

            String form = (String) req.getAttribute("formName");
            System.out.println("Type of form " +req.getAttribute("formName"));
            RequestDispatcher dispature = getServletContext().getRequestDispatcher("/DayCare.jsp");
            dispature.forward(req, resp);
        }
}
</code></pre>

<p>However, The servlet is returning null value for type of form</p>