title: I can't get a json object from servlet to jsp. How can I do?
body: <p>I am trying to pass a JsonObject to jsp. However, I think I cannot get the JsonObject using getAttribute method. How should I do to make this available.</p>
  
  <p>There's a Servlet code, below.</p>
  
  <pre><code> import java.io.IOException;
   import java.io.PrintWriter;
   import java.util.Iterator;
  
   import javax.servlet.ServletException;
   import javax.servlet.annotation.WebServlet;
   import javax.servlet.http.HttpServlet;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
   import javax.servlet.http.HttpSession;
  
   import com.google.gson.JsonObject;
   import com.google.gson.JsonParser;
  
   @WebServlet("/ShapeRendererFileManager")
   public class ShapeRendererFileManager extends HttpServlet {
      private static final long serialVersionUID = 1L;
     HttpSession session;
  
  //Send Json to jsp
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      response.setContentType("text/html;charset=euc-kr"); 
      session = request.getSession(true);
      //System.out.println(request.getParameter("tmp").toString());
      JsonObject jsonObject = new JsonObject();
      jsonObject.addProperty("name", "jinny");
      jsonObject.addProperty("title", "web");
  
      session.setAttribute("jsonObject", jsonObject);
      response.sendRedirect("index.jsp");
      }
   }
  </code></pre>
  
  <p>There's a jsp code below.</p>
  
  
  
  <pre><code>    &lt;%@page import="com.google.gson.JsonObject"%&gt;
  
      &lt;%@page import="com.google.gson.JsonElement"%&gt;
  
      &lt;%@page import="com.google.gson.JsonArray"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=EUC-KR"&gt;
  &lt;title&gt;start page&lt;/title&gt;
  &lt;/head&gt;
  &lt;%
      request.setCharacterEncoding("euc-kr");
      response.setContentType("text/html;charset=euc-kr");
      String tmp = "";
      JsonObject json = (JsonObject)session.getAttribute("jsonObject");
      tmp = json.get("name").toString(); //error at this line
  %&gt;
  &lt;body&gt;
  &lt;script&gt;
      $(function(){
          document.getElementByName("formtag").action="ShapeRendererFileManager";
          document.getElementById("formtag").submit();
      })
  &lt;/script&gt;
  
  &lt;h1&gt;&lt;%= tmp %&gt;&lt;/h1&gt;
  &lt;form name="formtag" action="" method="post"&gt;
  &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Thanks in advance.</p>