title: Setting a button value in session scope
body: <p>I am trying to set the value in session scope but it is not setting please find the problem exception is coming:</p>
  
  <p><code>&lt;%String name=request.getParameter("name");%&gt;&lt;% if(request.getParameter("name").equals(name)){session.setAttribute("EmployeeById",name);}%&gt;</code> </p>
  
  <p>Here you can find the code actually I want to set the button value in session and I am getting on other jsp.</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
           pageEncoding="ISO-8859-1" %&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %&gt;
  &lt;%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %&gt;
  &lt;%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %&gt;
  &lt;%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %&gt;
  
  &lt;html&gt;
  &lt;head&gt;
      &lt;script type="text/javascript"&gt;
          function popuponclick() {
              var mywindow = window.open("file.jsp", "file", "status=1,width=350,height=150");
          }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form name="form1"&gt;
      &lt;%String name = request.getParameter("name");%&gt;
  
      &lt;% if (request.getParameter("name").equals(name)) {
          session.setAttribute("EmployeeById", name);
      }
      %&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="submit" onclick="popuponclick()" value="GetEmployeeById" name="name"/&gt;
                  &lt;input type="hidden" name="GetEmp" value="1"&gt;&lt;/td&gt;
          &lt;/tr&gt;
  
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="submit" onclick="popuponclick()" value="GetEmployeeByname" name="name1"&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>my second .jsp is this where i m getting the value through session scope</p>
  
  <pre><code>    &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%&gt;
  &lt;%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%&gt;
  &lt;%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql"%&gt;
  &lt;%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml"%&gt;
  &lt;%@page
      import="com.nousinfo.tutorial.employee.service.model.bo.EmployeeBO"%&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  
  &lt;/head&gt;
  &lt;%
      String attributeValue = (String)session.getAttribute("EmployeeById");
  out.println(attributeValue);
  %&gt;
  &lt;body&gt;
  
  
  
  
  &lt;% if ("GetEmployeeById".equals(attributeValue)) { %&gt;
  &lt;div&gt;
  &lt;table&gt;
  &lt;tr&gt;
  &lt;td&gt;GetEmployeeByName&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;input type="text" name="GetEmployeeByName"/&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  &lt;% } else { %&gt;
  &lt;div&gt;
  &lt;table&gt;
  &lt;tr&gt;
  &lt;td&gt;GetEmployeeById&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;input type="text" name="GetEmployeeById"/&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  &lt;% } %&gt;
  &lt;table&gt;
  
              &lt;tr&gt;
                  &lt;td&gt;&lt;input type="submit" name="submit" value="find"&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>