Hi JSP experts,
I am having a JSP in my project which has some scriptlet code in the start and then javascript follows. Inside the javasript the values of variables defined inside the scriptlet code are accessed. The problem here is that most of the time this works very fine but at random or probably when this JSP page loads for the first time then it doesn't work.
The variable inside the scriplet code doesn't get initialized and then are not available inside the javascript. We are facing this issue at one of our customers and it has got escalted now. Any quick help would be much appreciated.
Please also find the initial JSP and the view source of the page below :
JSP :
<%@ page language="java" %>
<%@ taglib uri="/itc" prefix="itc" %>
<%@ page import="java.util." %>
<%@ page import="java.text." %>
<%@ page import="java.net.URLEncoder" %>
....
....
<%@ page import="com.sap.itc.admin.businessobject.manager.G lobalConfigManager" %>
<%@ page contentType = "text/html; charset=UTF-8" %>
<%@ include file="/common/nocache.jsp" %>
<%
final String employee = (String)request.getAttribute(ITCAdminConstants.EMP LOYEE);
final String hasPrepayProfile = (String)request.getAttribute(ITCAdminConstants.HAS _PREPAY_PROFILE);
final String orgOrEmpsNeedRecalc = (String)request.getAttribute(ITCAdminConstants.ORG _OR_EMPS_NEED_RECALC);
final String empNeedsRecalc = (String)request.getAttribute(ITCAdminConstants.EMP _NEEDS_RECALC);
final String resultsExported = (String)request.getAttribute(ITCAdminConstants.RES ULTS_EXPORTED);
final String newWeekSelected = (String)request.getAttribute(ITCAdminConstants.NEW _WEEK_SELECTED);
String empStartDateStr = null;
if (empStartDate != null)
{
empStartDateStr = TextUtils.formatDate(empStartDate, session);
}
...
...
//get userinfo and prepare effective date and day breaker
final UserInfo userInfo = UserInfo.getUserInfo(session);
...
...
int excpRows = 0; // number of rows in the punch exceptions table
int hourRows = 0; // number of rows in hour bins
int payRows = 0; // number of rows in pay bins
%>
<script language="JavaScript">
var g_use24HrTime = <%=userInfo.use24HrTime()%>;
var g_recalcAfterSave = <%=gcd.isRecalcAfterSave()%>;
var g_noEmployeeLoaded = <%= StringUtils.isEmpty(agtId) %>;
var g_hasPrepayProfile = <%= hasPrepayProfile %>;
...
...
</script>
<itc:frameController leftURL="/LoadSearchFilter.do" topURL="shell/navigation.jsp" layout="STANDARD_ISV" forceRefresh="true" selectedId="<%=agtId%>" />
<html>
<head>
<link type="text/css" href="/itcadmin/common/styles/iTimeClock.css" rel="stylesheet"/>
<script type="text/javascript" src="/itcadmin/common/scripts/calendar.js"></script>
...
...
<script type="text/javascript" src="/itcadmin/punches/evdata.js"></script>
<script language="javascript">
var week_day_str = new Array();
//=======================================benefits/adjustments======================================= ==========
var g_benadjustpopup_href = "/itcadmin/LoadBenAdjust.do";
function doBenAdjust(){
//set popup paramaters
var params = new Object();
params["empId"] = "<%=userInfo.getSelectedAgentId()%>"
params["employee"] = "<%=employee%>";
params["allowEditBenAdj"] = g_allowEditBenAdj ? "X" : "";
...
...
}
....
....
....
var g_processExcpMode = parent.frames[1].g_processExcpMode;
<%
if(!StringUtils.isEmpty(excpFilterId))
{
%>
g_processExcpMode = true;
<%
}
%>
var g_firstDayDefinition = <%=effDate.getDayOfWeek()%>; // default first day index
var g_rootOrgId = "<%= userInfo.getSelectedOrgId() %>";
var screenData = new Startup();
View Source :
<script language="JavaScript">
var g_use24HrTime = false; //None of these values are not getting updated according to the scriplet code
var g_recalcAfterSave = true;
var g_noEmployeeLoaded = true;
var g_hasPrepayProfile = false;
var g_orgOrEmpsNeedRecalc = false;
....
....
if(parent.frames[1]) // if left frame loaded
{
if(!g_noEmployeeLoaded) // employee is loaded; force a refresh of the emplist
{
parent.frames[1].g_processNewData = true;
}
}
</script>
<script language="JavaScript">try{ parent.g_processFrameSet("/itcadmin/LoadSearchFilter.do","/itcadmin/shell/navigation.jsp",parent.layouts.STANDARD_ISV, null, false, null, false);}catch(ignored) {}</script>
<html>
<head>
<link type="text/css" href="/itcadmin/common/styles/iTimeClock.css" rel="stylesheet"/>
<script type="text/javascript" src="/itcadmin/common/scripts/calendar.js"></script>
.....
....
<script type="text/javascript" src="/itcadmin/punches/evdata.js"></script>
<script language="javascript">
var week_day_str = new Array();
//=======================================benefits/adjustments======================================= ==========
var g_benadjustpopup_href = "/itcadmin/LoadBenAdjust.do";
function doBenAdjust(){
//set popup paramaters
var params = new Object();
params["empId"] = "null" //Notice this value is not getting filled
params["employee"] = "null"; //Notice this value is not getting filled
params["allowEditBenAdj"] = g_allowEditBenAdj ? "X" : "";
var ba_popup = new Popup(g_benadjustpopup_href, 680, 500, null, params);
...
...
}
....
....
....
var g_firstDayDefinition = 1; // default first day index //Notice these values still got filled
var g_rootOrgId = "70000724"; //Notice these values still got filled
var screenData = new Startup();