Solved

JSP page with JavaScript losses its settings on browser back

Posted on 2003-11-07
5
233 Views
Last Modified: 2010-04-01
I ported a CGI based page from Apache to jsp on SunOne.  It has a JavaScript pop up calendar from SoftComplex (nice).  The form also has other text entry locations.  If only the text entry values are used, and the form submited, when I hit BACK they are still present in the edit fields.

If I use the JavaScript calendar, then submit,  on BACK all fields are cleared even the text boxes.  This was not the case with the CGI based page.  I have both, runing at the same time agains the same browser and only the JSP page exhibits this behavior.

Would there be something that forces SunOne to re-complie the JSP, of otherwise force the page back to the browser?

Hope this makes sense, and thanks for any pointers.

Chris
0
Comment
Question by:sads
  • 2
  • 2
5 Comments
 
LVL 27

Accepted Solution

by:
rrz earned 200 total points
ID: 9704614
>Would there be something that forces SunOne to re-complie the JSP  
No, I don't think so.
When you click "Back", you are not going back to the server but the browser's cache.
Sounds like a javascript problem to me.
Please show us your code.
0
 

Author Comment

by:sads
ID: 9705131
This is the entire page in question (below)..  The pages it calls use Beans and EJBs for data manipulation.  In looking at it theres no reason for this to be jsp, but I guess that should not matter.  Thanks in advance for any pointers...

Oh, a bunch of this was added with Dreamweaver

This is a calendar usage:

      <td colspan="3" height="22"><b>
        <input type="Text" name="fromDate" value="">
        <a href="javascript:cal5.popup();"><img src="img/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"></a>
        </b> </td>


The is definition at the bottom:

var cal5 = new calendar1(document.forms['SearchForm'].elements['fromDate']);
cal5.year_scroll = true;
cal5.time_comp = false;





--------------------------


<%@ page contentType="text/html" %>
<%@ page language="java" import="javax.naming.*" %>
<%@ page import="javax.rmi.PortableRemoteObject,java.util.*" %>


<html>
<head>



<style>
<!--
.mouseBeOffMe {
border-top:    10px  solid #FFFFFF;
border-bottom: 10px  solid #FFFFFF;
border-left:   6px   solid #FFFFFF;
border-right:  10px  solid #FFFFFF;
}
.mouseBeOnMe {
border-top:    6px   solid #FFFFFF;
border-bottom: 14px  solid #FFFFFF;
border-left:   6px  solid #FFFFFF;
border-right:  10px   solid #FFFFFF;
}
.mouseBeDown {
border-top:    13px  solid #FFFFFF;
border-bottom: 7px   solid #FFFFFF;
border-left:   0px  solid #FFFFFF;
border-right:  0px   solid #FFFFFF;
}
.mouseBeUp {
border-top:    10px  solid #FFFFFF;
border-bottom: 10px  solid #FFFFFF;
border-left:   0px  solid #FFFFFF;
border-right:  0px   solid #FFFFFF;
}

.mouseMoveDown {
border-top:    13px  solid #FFFFFF;
border-bottom: 7px   solid #FFFFFF;
border-left:   0px  solid #FFFFFF;
border-right:  0px   solid #FFFFFF;
}
.mouseMoveUp {
border-top:    10px  solid #FFFFFF;
border-bottom: 10px  solid #FFFFFF;
border-left:   0px  solid #FFFFFF;
border-right:  0px   solid #FFFFFF;

}
//-->
</style>






<title>Search 2.0</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" src="calendar1.js"></script>
<!-- Date only with year scrolling -->
      <style>

      </style>
      <link rel="stylesheet" href="tmsSearchStyle.css" type="text/css">
      <link rel="stylesheet" href="tmsStyle.css" type="text/css">
      <link rel="stylesheet" href="menus/menu.css">
<script language="JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function runSubmit() {
    if ((document.SearchForm.TransRefNum.value.length == 0)
                            && (document.SearchForm.AccountNumber.value.length == 0)
                            && (document.SearchForm.CustName.value.length == 0)
                            && (document.SearchForm.OrigTransRef.value.length == 0)
                            && (document.SearchForm.InFileName.value.length == 0)) {
            if ((document.SearchForm.fromDate.value.length == 0) || (document.SearchForm.toDate.value.length == 0)) {          
                alert('Please enter search values, see Help-Queries for details');
                  return false;
          }            
    }            
    return true;            

}

//-->
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000" onLoad="MM_preloadImages('buttons/clearSearchOver.gif','buttons/startSearchOver.gif')">
<form name="SearchForm" method="post" action="transactionResultsView.jsp" >
  <table border="0" bgcolor="#FFFFFF" width="97%">
    <tr>
      <td bgcolor="#FFFFFF" colspan="4" height="66"><img src="localImg/direct_energy.gif" width="351" height="53"></td>
      <td bgcolor="#FFFFFF" width="72" height="66">
        <div align="center"><font size="+3" color="#006393"></font></div>
      </td>
      <td colspan="4" bgcolor="#FFFFFF" height="66">
        <div align="center"> <b></b></div>
      </td>
    </tr>
    <tr>
      <td colspan="9" height="81"><b><i></i></b> </td>
    </tr>
    <tr>
      <td colspan="9" height="46">
        <h1 align="center"><font face="Tahoma" size="5">Transaction Search</font></h1>
      </td>
    </tr>
    <tr>
      <td height="26" colspan="3"><font face="Tahoma" size="2"><b>Transaction
        Reference Number </b></font></td>
      <td height="26" colspan="3"><b> </b> <b> </b> <b>
        <input type="text" name="TransRefNum" maxlength="50" size="35">
        </b></td>
      <td height="26" width="218"><b><font face="Tahoma" size="2">Sending Utility
        Name</font></b></td>
      <td height="26" colspan="2" width="263"> <b>
        <input type="text" name="SendUtilityName" maxlength="50" size="35">
        </b></td>
    </tr>
    <tr>
      <td height="19" colspan="3"><font face="Tahoma" size="2"><b>Account Number
        </b></font></td>
      <td height="19" colspan="3"><b> </b> <b> </b> <b>
        <input type="text" name="AccountNumber" maxlength="50" size="35">
        </b></td>
      <td height="19" width="218"><b><font face="Tahoma" size="2">Sending Utility
        OEB #</font></b></td>
      <td height="19" colspan="2" width="263"> <b>
        <input type="text" name="SendUtilityNum" maxlength="40" size="35">
        </b></td>
    </tr>
    <tr>
      <td height="33" colspan="3"><font face="Tahoma" size="2"><b>Customer Name
        </b></font></td>
      <td height="33" colspan="3"> <b> </b> <b>
        <input type="text" name="CustName" size="35" maxlength="50">
        </b></td>
      <td height="33" width="218"><b><font face="Tahoma" size="2">Receiving Utility
        Name</font></b></td>
      <td height="33" colspan="2" width="263">
        <input type="text" name="RecUtilityName" size="35" maxlength="50">
      </td>
    </tr>
    <tr>
      <td height="20" colspan="3"><b><font face="Tahoma" size="2">Original Transaction
        Ref Number</font></b></td>
      <td height="20" colspan="3"> <b>
        <input type="text" name="OrigTransRef" size="35" maxlength="50">
        </b></td>
      <td height="20" width="218"><b><font face="Tahoma" size="2">Receiving Utility
        OEB #</font></b></td>
      <td height="20" colspan="2" width="263"> <b>
        <input type="text" name="RecUtilityNum" size="35" maxlength="40">
        </b></td>
    </tr>
    <tr>
      <td colspan="3"><b><font face="Tahoma" size="2">Incoming File Name</font></b></td>
      <td colspan="3"> <b> </b>
        <input type="text" name="InFileName" size="35" maxlength="50">
      </td>
      <td width="218"><b><font face="Tahoma" size="2">Transaction Type</font></b></td>
      <td colspan="2" width="263"><b>
        <select name="TransType">
          <option selected>ALL</option>
          <option>None</option>
        </select>
        </b></td>
    </tr>
    <tr>
      <td height="22" colspan="3"><b><font face="Tahoma" size="2">Record Load
        Date </font></b></td>
      <td height="22" colspan="3"><b> </b></td>
      <td height="22" width="218"><b><font face="Tahoma" size="2">Direction</font></b></td>
      <td height="22" colspan="2" width="263">
        <select name="Direction">
          <option selected>N/A</option>
          <option>Inbound to DE</option>
          <option>Outbound From DE</option>
        </select>
      </td>
    </tr>
    <tr>
      <td height="22" colspan="3">
        <p><font face="Tahoma" size="2"><b> From (dd-mm-yyyy)</b> </font></p>
      </td>
      <td colspan="3" height="22"><b>
        <input type="Text" name="fromDate" value="">
        <a href="javascript:cal5.popup();"><img src="img/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"></a>
        </b> </td>
      <td height="22" width="218"><b><font face="Tahoma" size="2">Distribution
        Status</font></b></td>
      <td height="22" colspan="2" width="263"> <b>
        <select name="LoadStatus">
          <option selected>N/A</option>
          <option>Not Loaded</option>
          <option>Pending</option>
          <option>Held</option>
          <option>Load OK</option>
          <option>Load Failed</option>
        </select>
        </b></td>
    </tr>
    <tr>
      <td height="29" colspan="3"><b><font face="Tahoma" size="2">To (dd-mm-yyyy)</font></b></td>
      <td height="29" colspan="3"><b>
        <input type="Text" name="toDate" value="">
        <a href="javascript:cal6.popup();"><img src="img/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"></a>
        </b> <i><b></b></i></td>
      <td height="29" width="218"><i><b><font color="#FF6600" face="Tahoma" size="2">Distribution
        Date </font></b></i></td>
      <td height="29" width="263"><i><b><font color="#FF6600" face="Tahoma" size="2">(Settlements
        / Energy....)</font></b></i></td>
    </tr>
    <tr>
      <td colspan="3"><b><font face="Tahoma" size="2"> Load Status</font></b></td>
      <td colspan="3"><b>
        <select name="LoadErrors">
          <option selected>N/A</option>
          <option>No Errors</option>
          <option>All Errors</option>
          <option>Duplicates</option>
          <option>Syntax Error</option>
        </select>
        </b> </td>
      <td width="218"><font color="#FF6600" face="Tahoma" size="2"><b><i>From
        (dd-mm-yyyy)</i></b> </font></td>
      <td colspan="2" width="263"><b>
        <input type="Text" name="loadFromDate" value="">
        <a href="javascript:cal7.popup();"><img src="img/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"></a></b></td>
    </tr>
    <tr>
      <td colspan="3"><font face="Tahoma" size="2"><b>Max Records to Return</b>
        </font></td>
      <td colspan="3">
        <input type="text" name="MaxRecords" value="1000" size="8" maxlength="4">
      </td>
      <td width="218"><font color="#FF6600" face="Tahoma" size="2"><b><i>To (dd-mm-yyyy)</i></b>
        </font></td>
      <td colspan="2" width="263"><b>
        <input type="Text" name="loadToDate" value="">
        <a href="javascript:cal8.popup();"><img src="img/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"></a></b>
      </td>
    </tr>
    <tr>
      <td height="23" width="56"><b><font face="Tahoma" size="2">NOTE(S):</font></b></td>
      <td width="132" height="23"><font face="Tahoma" size="2"></font></td>
      <td height="23" colspan="4"><font face="Tahoma" size="2"></font></td>
      <td height="23" colspan="2"><b>
        <input type="hidden" name="Search" value="Start Search">
        </b></td>
    </tr>
    <tr>
      <td colspan="6" height="35"><b><i><font color="#000000" face="Tahoma" size="2">**
        </font><font color="#FF6600" face="Tahoma" size="2">Italic</font> </i><font face="Tahoma" size="2">means
        not implemented yet.</font></b></td>
      <td width="218" height="72" rowspan="2"><b><a href="javascript:document.SearchForm.submit()" title="Start Search" onClick="return runSubmit()" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Start Search','','buttons/startSearchOver.gif',1)"><img name="Start Search" border="0" src="buttons/startSearchUp.gif" width="86" height="30" onMouseDown = "this.className='mouseMoveDown'" onMouseUp = "this.className='mouseMoveUp'"></a>
        </b></td>
      <td height="72" colspan="2" width="263" rowspan="2"><b><i><a href="javascript:document.SearchForm.reset()" title="Clear Search Parameters" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Clear Search','','buttons/clearSearchOver.gif',1)" ><img name="Clear Search" border="0" src="buttons/clearSearchUp.gif" width="86" height="30" onMouseDown = "this.className='mouseMoveDown'" onMouseUp = "this.className='mouseMoveUp'"></a>
        </i> </b></td>
    </tr>
    <tr>
      <td colspan="6" height="35"><b><font face="Tahoma" size="2">** Use the '%'
        as a wildcard at the end of text fields.</font></b></td>
    </tr>
    <tr>
      <td colspan="9" height="20">
        <h1 align="right">
          <script language="JavaScript">
now = new Date();
var mon = now.getMonth() + 1;
document.write("Date: " + mon +"/");
document.write(now.getDate()+"/");
document.write(now.getFullYear());
</script>
        </h1>
      </td>
    </tr>
    <tr>
      <td colspan="9" height="51"></td>
    </tr>
  </table>
</form>
<script language="JavaScript">
<!-- // create calendar object(s) just after form tag closed -->


var cal5 = new calendar1(document.forms['SearchForm'].elements['fromDate']);
cal5.year_scroll = true;
cal5.time_comp = false;
var cal6 = new calendar1(document.forms['SearchForm'].elements['toDate']);
cal6.year_scroll = true;
cal6.time_comp = false;
var cal7 = new calendar1(document.forms['SearchForm'].elements['loadFromDate']);
cal7.year_scroll = true;
cal7.time_comp = false;
var cal8 = new calendar1(document.forms['SearchForm'].elements['loadToDate']);
cal8.year_scroll = true;
cal8.time_comp = false;

</script>
<script language="JavaScript" src="menus/menu.js"></script>
<script language="JavaScript" src="menus/menu_items.js"></script>
<script language="JavaScript" src="menus/menu_tpl.js"></script>
<script language="JavaScript">
      <!--
      new menu (MENU_ITEMS, MENU_POS);
      //-->
</script>

</body>
</html>
0
 
LVL 27

Assisted Solution

by:rrz
rrz earned 200 total points
ID: 9705516
I don't khow if I can help much but maybe some expert will look at your code.  

Are you saying, that the form is submitted and that  transactionResultsView.jsp  responses with the correct results ?   Afer that, you click the Back button and have your problem with your fields.  Is that right ?   Was the submission method="post" for the CGI page as well ?    
0
 

Author Comment

by:sads
ID: 9705524
Yes to all.... Post for both.  The interesting thing is... that if the date field (calendar) is not used the fields are still filled with the values used in the search.  If the date field is used (via the calendar), then ALL fields are cleared.  Typing this, I think I will run a test and type in the date and NOT use the calendar and see what effect that has..
0
 
LVL 14

Assisted Solution

by:kennethxu
kennethxu earned 50 total points
ID: 9708774
>> Typing this, I think I will run a test and type in the date and NOT use the calendar and see what effect that has..
is your problem resolved? if not, can you let us know the result of your test above?
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
In this article, I will show you HOW TO: Create your first Windows Virtual Machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, the Windows OS we will install is Windows Server 2016.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now