title: Typecasting error in sessions in jsp
body: <p>I have a jsp file adminLogin.jsp where i check the session attributes passed on from index.jsp and from logout.jsp :</p>
  
  <pre><code>&lt;%
        String s=(String)session.getAttribute("wrongP");
      if(s.equals('0'))
      {out.println("Wrong Details or you logged out Please Login Again &lt;br&gt;");
      session.invalidate();
      }
  
      %&gt;
      This is login 
  
  form
      &lt;br&gt;Please login&lt;br&gt;
  
              &lt;form method="GET" action="login1"&gt;
               &lt;br&gt;.           Id:&lt;input type="text" name="id"&gt;&lt;br&gt;Password:&lt;input
                      type="password" name="pass"&gt;&lt;br&gt; &lt;input type="submit"
                      value="Submit"&gt;
              &lt;/form&gt;
              &lt;/div&gt;
  </code></pre>
  
  <p>The error i am getting is:</p>
  
  <pre><code>HTTP Status 500 - An exception occurred processing JSP page /adminLogin.jsp at line 12
  </code></pre>
  
  <hr>
  
  <blockquote>
    <p>type Exception report</p>
  
  <pre><code>message An exception occurred processing JSP page /adminLogin.jsp at line 12
  
  description The server encountered an internal error that prevented it from fulfilling this request.
  
  exception 
  
  org.apache.jasper.JasperException: An exception occurred processing JSP page /adminLogin.jsp at line 12
  
  9: &lt;body&gt;
  10: &lt;div align="center"&gt;
  11: &lt;%
  12: String s=(String)session.getAttribute("wrongP");
  13: if(s.equals('0'))
  14: {out.println("Wrong Details or you logged out Please Login Again &lt;br&gt;");
  15: session.invalidate();
  
  
  Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  
  
  root cause 
  
  java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.String
    org.apache.jsp.adminLogin_jsp._jspService(adminLogin_jsp.java:72)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  
  
  note The full stack trace of the root cause is available in the Apache Tomcat/7.0.53 logs.
  </code></pre>
  </blockquote>
  
  <p>I type casted the attribute but i am still getting this error.</p>