title: how to compare two strings using if condition inside jsp page?
body: <p>Jsp code:</p>
  
  <pre><code>&lt;% 
  String usermailid=(String)session.getAttribute("Username");
  System.out.println("value of session==="+usermailid.equals("null"));
  String empty=null;
  
  if(usermailid.equals("null")) {   
  
  %&gt;                          
  
  
  
  &lt;% } 
  
  else
  {%&gt;
  
  
  &lt;%}%&gt;
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>Apr 7, 2014 5:39:31 PM org.apache.catalina.core.StandardWrapperValve invoke
  SEVERE: Servlet.service() for servlet jsp threw exception
  java.lang.NullPointerException
      at org.apache.jsp.election_005fresults_jsp._jspService(election_005fresults_jsp.java:437)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
      at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>In the above code i want to compare two strings.but when ever i comapare them i am getting null pointer exception when both the values are null and showing value as false??
  so can anyone tell me what is the exact way of comparing two string???</p>