title: Get Attribute variable passed from servlet
body: <p>All, I have a attribute variable set in the servlet. and want to get it in the jsp.
  But I have some questions about it. 
  Say you have the code .</p>
  
  <p>In the servlet.</p>
  
  <pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          request.setAttribute("BeerSelected", "BlackBeer");
          RequestDispatcher disp=request.getRequestDispatcher("SelectResult.jsp");
          disp.forward(request,response);
      }
  </code></pre>
  
  <p>In the JSP</p>
  
  <p>this code works</p>
  
  <pre><code>&lt;%String name = (String)request.getAttribute("BeerSelected");%&gt;
  &lt;%= name%&gt;
  </code></pre>
  
  <p>But why below code doesn't work? jsp doesn't render the value .</p>
  
  <pre><code>&lt;%request.getAttribute("BeerSelected");%&gt;
  </code></pre>
  
  <p>Neither does below code.</p>
  
  <pre><code>&lt;%request.getAttribute("BeerSelected").toString();%&gt;
  </code></pre>
  
  <p>I don't know why <code>toString()</code> doesn't work. thannks.</p>