title: how to show/hide a div on page1.jsp when a function got success in a page2.jsp using ajax/jquery?
body: <h2>page1.jsp</h2>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;  
  &lt;script src="js/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;    
  
      &lt;/head&gt;  
      &lt;body&gt;
      &lt;form id="registe" action="" novalidate&gt;  
          &lt;input type="hidden" name="txtCaptcha" id="txtCaptcha" value="42988715"&gt;        
          &lt;input id="" type="text" name="nam" placeholder="your name"&gt;&lt;br&gt;
          &lt;input id="textbox1" type="text" name="name" onchange="showState(this.value)" placeholder="e-mail"/&gt;
          &lt;div id='mailres'&gt;
  &lt;!--text from get_mail.jsp--&gt;
          &lt;/div&gt;
          &lt;div id='emailcode' style='display:none;'&gt;
  &lt;input type="text" name="code" placeholder="code from email"&gt;
          &lt;/div&gt;
          &lt;input id="" type="text" name="phone" placeholder="phone"/&gt; &lt;br&gt;
          &lt;input id="" type="text" name="city" placeholder="city"/&gt; &lt;br&gt;
      &lt;/form&gt;
  &lt;script language="javascript"&gt;
  //Generates the captcha function    
      var a = Math.ceil(Math.random() * 9)+ '';
      var b = Math.ceil(Math.random() * 9)+ '';       
      var c = Math.ceil(Math.random() * 9)+ '';  
      var d = Math.ceil(Math.random() * 9)+ '';  
      var e = Math.ceil(Math.random() * 9)+ '';
      var f = Math.ceil(Math.random() * 9)+ '';     
      var g = Math.ceil(Math.random() * 9)+ '';     
      var h = Math.ceil(Math.random() * 9)+ '';     
  
      var code = a + b + c + d + e + f + g + h;
      document.getElementById("txtCaptcha").value = code;
      document.getElementById("txtCaptchaDiv").innerHTML = code;  
  
  // Validate the Entered input aganist the generated security code function   
  function ValidCaptcha(){
      var str1 = removeSpaces(document.getElementById('txtCaptcha').value);
      var str2 = removeSpaces(document.getElementById('txtInput').value);
      if (str1 == str2){
          return true;    
      }else{
          return false;
      }
  }
  
       function removeSpaces(string){
      return string.split(' ').join('');
  }
  &lt;/script&gt;         
  &lt;script language="javascript"&gt;  
              var xmlHttp  
              var xmlHttp
              function showState(str){ 
                  if (typeof XMLHttpRequest != "undefined"){
                      xmlHttp= new XMLHttpRequest();
                  }
                  else if (window.ActiveXObject){
                      xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
                  }
                  if (xmlHttp==null){
                      alert ("Browser does not support XMLHTTP Request")
                      return
                  } 
                  var url="get_mail.jsp";//goes to get_mail.jsp
                  url += "?count=" +document.getElementById("textbox1").value;
                  url += "&amp;code=" +document.getElementById("txtCaptcha").value;
                  xmlHttp.onreadystatechange = stateChange;
                  xmlHttp.open("GET", url, true);
                  xmlHttp.send(null);
  
              }
              function stateChange()
              {   
                  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){   
                      document.getElementById("mailres").innerHTML = xmlHttp.responseText;  
  
                  }   
              }
  &lt;/script&gt;  
      &lt;/body&gt; 
  &lt;/html&gt;
  </code></pre>
  
  <h2>page2.jsp</h2>
  
  <pre><code>&lt;%@page import=" java.util.Properties" %&gt;   
  &lt;%@page import="javax.mail.BodyPart" %&gt;  
  &lt;%@page  import=" javax.mail.Message" %&gt; 
  &lt;%@page  import ="javax.mail.MessagingException" %&gt; 
  &lt;%@page import ="javax.mail.Multipart" %&gt; 
  &lt;%@page import ="javax.mail.SendFailedException" %&gt; 
  &lt;%@page import=" javax.mail.Session"  %&gt; 
  &lt;%@page import ="javax.mail.Transport"%&gt; 
  &lt;%@page import ="javax.mail.internet.InternetAddress"%&gt; 
  &lt;%@page import=" javax.mail.internet.MimeBodyPart" %&gt; 
  &lt;%@page import=" javax.mail.internet.MimeMessage"  %&gt; 
  &lt;%@page import="javax.mail.internet.MimeMultipart" %&gt;  
  
  
  &lt;html&gt;
  &lt;head&gt;
  &lt;script src="js/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;    
  &lt;/head&gt;
  &lt;body&gt;
  &lt;%
      String s=request.getParameter("count");
      String code = request.getParameter("code");
      if(s.equals("") || s.equals("null"))
      {
          out.println("Please type the email");
      }
      else
      {
  
          String emailidto= request.getParameter("count");
          String code1 = request.getParameter("code");
          String paswd="password";
          String wrongid="";
          String username="samuel";
          String host = "smtp.gmail.com";
          String Password = "*********";
          String from = "*******@gmail.com";
          String toAddress = emailidto;  //Receiver’s email id     
          Properties props = System.getProperties();
          props.put("mail.smtp.host", host);
          props.put("mail.smtps.auth", "true");
          props.put("mail.smtp.starttls.enable", "true");
  
          Session session1 = Session.getInstance(props, null);
  
          MimeMessage message = new MimeMessage(session1);
  
          message.setFrom(new InternetAddress(from));
  
          try
          {           
  
          message.setRecipients(Message.RecipientType.TO, toAddress);
  
          }
          catch(Exception e)
          {
              e.printStackTrace();
          }
  
          message.setSubject("Test Email");
  
          BodyPart messageBodyPart = new MimeBodyPart();
  
          message.setSubject("Code to complete Enquiry");
  
          String content = new String("Please copy this code:&amp;nbsp;&lt;h2&gt;&lt;span style='color:red;'&gt;"+code1+"&lt;/span&gt;&lt;/h2&gt;"); 
  
          messageBodyPart.setContent(content, "text/html");
  
          Multipart multipart = new MimeMultipart();
  
          multipart.addBodyPart(messageBodyPart);
  
          messageBodyPart = new MimeBodyPart();     
  
          message.setContent(multipart);
  
          try 
          {
              Transport tr = session1.getTransport("smtps");
              tr.connect(host, from, Password);
              tr.sendMessage(message, message.getAllRecipients());            
              tr.close();
          } 
          catch (SendFailedException sfe) 
          {
                out.println(sfe);
          }
      }
     %&gt;
  &lt;!--JSP mail send--&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I'm making a contact form which send mail to the user when email is typed. So on the 'page1.jsp' the user enters email, then on 'page2.jsp' retrieves the email address and sends to the user for authentication. My question is when the email is send from the 'page2.jsp' I want some trigger to show the hidden div on the 'page1.jsp'.
  Here in the hidden div there is a textbox which suppose to be appear when a mail is successfully delivered, so that the user may enter the code by copying from his email .And here the user never see the 'page2.jsp'. </p>
  
  <h1>If understood please help me.</h1>
  
  <p>I'm new in this form and got help from 'STACKOVERFLOW' more than a 100 times for my project mainly in JSP.</p>
  
  <p>I've tried and search every where about the above question, but haven't found any.</p>
  
  <p>I believe here there are very talented guru's to help me.</p>
  
  <p>Thanks in advance Guru's.</p>