title: how to call java script function of other jsp page script function
body: <p>I want to call JavaScript function on <code>index.jsp</code> from <code>file.jsp</code> here is my code  after getting the value in index.jsp script function then I want to call servlet from inside those function</p>
  
  <p>this is my index.jsp</p>
  
  <pre><code>&lt;%@page import="org.apache.catalina.connector.Request"%&gt;
  &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");
             }
             function onLoadById(long id)
             {
                after getting value call the servlet GetEmployeeServlet passing id as a parameter
             }
             function onLoadByname(String name)
             {
                after getting value call the servlet GetEmployeeServlet passing name as a parameter
             }    
       &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
  
      &lt;form name="form1"&gt;
  
      &lt;%String name11=request.getParameter("name"); 
      out.println(name11);%&gt;
          &lt;% if(name11!=null){
              out.println(name11);
              session.setAttribute("EmployeeById","1");}
          %&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>and this is my file .jsp</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;script&gt;
  function myfuntion()
  {
      var d=document.getElementById('first');
      var c=document.getElementById('second');
      alert(window.parent);
      window.close();
      }
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;bod&gt;
  
  &lt;% if (session.getAttribute("EmployeeById")!=null) {
      session.removeAttribute("EmployeeById");
  %&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 id="first" 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 id="second" 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 id="submit"  type="submit" name="submit" value="find" onclick="myfuntion()"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>