c:forEach does not iterate all values - java

I have a arraylist tagged to a session, and when i try to iterate with c:forEach, it shows only first two class and there attributes, and when it comes to third class element in that arraylist, it just doesnt show values of attributes.
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%# taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%# page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<table id="myTable">
<c:choose>
<c:when test="${jednaRez.stoRez.zauzetostStola == false || nema == true}">
<tr>
<td style="border: 0;">
<p style="font-size: 15px;">
&nbsp &nbspZauzetost stola: &nbsp <b>Slobodan </b>
</p>
</td>
</tr>
</c:when>
<c:otherwise>
<c:forEach items="${rezeSto}" var="rezSto">
<tr>
<td style="border: 0;">
<p style="font-size: 15px;">
&nbsp &nbspZauzetost stola: &nbsp <b>Zauzet </b>
</p>
</td>
</tr>
<tr>
<td style="border: 0;">
<p style="font-size: 15px;">
&nbsp &nbspDatum rezervacije: &nbsp <b> <span id="datumRez"> ${rezSto.datumRezervacije} </span> </b>
</p>
</td>
</tr>
<tr>
<td style="border: 0;">
<p style="font-size: 15px;">
&nbsp &nbspTrajanje rezervacije: &nbsp <b> ${rezSto.rezervacijaTrajanje} </b>
</p>
</td>
</tr>
<tr>
<td style="border: 0;">
<p style="font-size: 15px;">
&nbsp &nbspKorisnici:<b> &nbsp ${rezSto.gost.korisnikIme} &nbsp ${rezSto.gost.korisnikPrezime} &nbsp </b><!-- <c:forEach items="${rezSto.pozvaniPrijatelji}" var="pri"> ,<b> ${pri.gost.korisnikIme} &nbsp ${pri.gost.korisnikPrezime} </b> , </c:forEach>--> <br/>
____________________________________________________________
</p>
</td>
</tr>
<br/>
</c:forEach>
</c:otherwise>
</c:choose>
</table>
Any ideas?
This is servlet where i create arrayList rezeSto:
Korisnik men = (Korisnik) request.getSession().getAttribute("menadzer");
ArrayList<Rezervacija> sveRez = new ArrayList<Rezervacija>(rezervacijaDao.rezRestoran(men.getRestoran().getId()));
ArrayList<Rezervacija> vazeceRez = null;
try {
vazeceRez = new ArrayList<Rezervacija>((List<Rezervacija>)men.vazeceRez(sveRez));
} catch (ParseException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
ArrayList<Rezervacija> rezStoIsti = new ArrayList<Rezervacija>();
//samo one rezervacije koje sadrze poslati sto
for(int i=0; i<vazeceRez.size(); i++)
{
if(vazeceRez.get(i).getStoRez().getId().equals(sifraStola))
{
rezStoIsti.add(vazeceRez.get(i));
}
}
request.getSession().setAttribute("nema", false);
if(rezStoIsti.size() == 0)
{
request.getSession().setAttribute("nema", true);
}
else
{
request.getSession().setAttribute("jednaRez", rezStoIsti.get(0));
request.getSession().setAttribute("rezeSto", rezStoIsti);
}
request.getRequestDispatcher("stoPrikaz.jsp").forward(request, response);
return;

If c:forEach prints first two and and you don not see the other list elements, i would suppose that when the second is got printed it breaks your html, that's why you don't see it, try to debug maybe really some special character gets printed out.

Related

Sending data using <a href="#"> in the same page and display the result (FORM) using JSP without changing the (FORM) coding

<div id="main_search">
<table>
<tr>
<td>Product</td>
<td>:</td>
<td>
<input type="checkbox" name="product" class="prod_checkbx" value="Bilateral-VC">Bilateral-VC
<br>
<input type="checkbox" name="product" class="prod_checkbx" value="Bilateral Non-VC">Bilateral Non-VC
<br>
<input type="checkbox" name="product" class="prod_checkbx" value="Budget Domestic">Budget Domestic
<br>
<input type="checkbox" name="product" class="prod_checkbx" value="Budget High">Budget High
<br>
<input type="checkbox" name="product" class="prod_checkbx" value="Budget International">Budget International
<br>
<input type="checkbox" name="product" class="prod_checkbx" value="IDD Buffet Base">IDD Buffet Base
<br>
<input type="checkbox" name="product" class="prod_checkbx" value="Premium">Premium
<br>
</td>
</tr>
<tr>
<td>Destination</td>
<td>:</td>
<td>
<input id="destination" type="text" name="destination" />
</td>
</tr>
<tr>
<td colspan="9" align="center">
<a id="search" name="search" class="button orange small" style="cursor:pointer" href="#">SEARCH</a>
</td>
</tr>
</table>
</div>
<div id="search_result" style="overflow: auto;">
<h2>Floor Price Edit</h2>
<table id="result-tbl" class="searchTable">
<tr>
<th>Destination</th>
<th>Product</th>
</tr>
<tr>
<% String dest=r equest.getParameter( "destination"); %>
<td>
<%=d est %>
</td>
</tr>
<% if (dest !=n ull) { %>
<sql:setDataSource var="db" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3307/icars" user="root" password="" />
<sql:query var="dest_result" dataSource="${dbsource}">
SELECT * from icx_pricing_desk WHERE DESTINATION LIKE '
<%=d est %>%'
</sql:query>
<c:forEach var="row" items="${dest_result.rows}">
<tr>
<td>
<c:out value="${row.DESTINATION}" />
</td>
</tr>
</c:forEach>
<% } %>
<td>
<% String products[]=r equest.getParameterValues( "product"); %>
<% if(products !=n ull) { %>
<% for(int i=0; i<products.length; i++) { %>
<%=products[i]%>
<sql:query var="prod_result" dataSource="${db }">SELECT * FROM icx_pricing_desk WHERE PRODUCT = '
<%=products[i]%>'</sql:query>
<c:forEach var="row" items="${prod_result.rows}">
<tr>
<td>
<c:out value="${row.PRODUCT}" />
</td>
</tr>
</c:forEach>
<% } } %>
</td>
</table>
</div>
This is some kind of form without <form> tag and for submit button it didn't use <input type="submit"> like normal form. It use <a href="#"> to submit the data.
The question is how do you send the data using the <a href="#">???
In addition, when i click the SEARCH button both <% String dest = request.getParameter("destination"); %> and <% String products[]= request.getParameterValues("product"); %> didn't received any data.
When using the standard form, both can display result. This code is written in same page(JSP).
--The first coding cannot be changed because it was the assignment and need to solve it.--
Add a form tag in your code like
<form name="form1" method="POST">
<table>
<!-- Your code ->
<a id="search" name="search" class="button orange small" style="cursor:pointer" href="javascript:void(0);" onclick="document.form1.submit();">SEARCH</a>
</table>
</form>
Things to remember
Form tag: method(POST), Name of form(form1)
Method called on onclick of a tag

How to pass variables defined in one jsp to another and then again after processing in another jsp include that jsp in first jap page

I need to pass values from one jsp to another jsp and then the values are processed in that another jsp and then that jsp will be included in first jsp.
The jsp variables which I need to pass are from Comp_Mps_hs.jsp to Comp_Mps_hs_diff.jsp are
<jsp:useBean id="ref" class="comp_Mps.Comp_Mps_hs"/>
<br>
<%
//Comaprision obj = new Comaprision();
String s_date= request.getParameter("startdate");
pageContext.setAttribute("s_date", s_date);
String e_date= request.getParameter("enddate");
pageContext.setAttribute("e_date", e_date);
ref.refarray_vac1(s_date,e_date);
ref.ClosestToMultiplesOfTen_User(s_date,e_date);
%>
<%
//Comaprision reference = new Comaprision();
String ref_name= request.getParameter("ref_logtime");
pageContext.setAttribute("ref_name", ref_name);
ref.FindClosestToMultiplesOfTen(ref_name);
ref.refernece(ref_name);
%>
<br><br><br>
<table width = "170%" border = "1" cellspacing="0" cellpadding="0">
<tr>
<th>Date_Time</th>
<th>beam_current</th>
<th>beam_energy</th>
<%
for(int i=51; i<99;i++){
%>
<th>p<%=i%>_readback</th>
<th>p<%=i%>_setvalue</th>
<th>p<%=i%>_vmeset</th>
<th>p<%=i%>_dacbyadc</th>
<%
}
%>
<!--
</tr>
<c:set var="count" value="0" scope="session" />
<c:forEach var="row" items="${ref.refarray_vac1(param.startdate,param.enddate)}">
<c:forEach var="r" items="${ref.refernece(param.ref_logtime)}" begin="${count}" end="${count}">
<tr bgcolor="darkgray ">
<td><c:out value="${r.logtime}"></c:out></td>
<td>
<c:out value="${r.beam_current}"></c:out> </td>
<td>
<c:out value="${(r.beam_energy)}"/>
</td>
<td>
<fmt:formatNumber value="${(r.p51_readback)}" maxFractionDigits="2" minIntegerDigits="2" var="mm"></fmt:formatNumber>
<c:out value="${(r.p51_readback)}"/>
</td>
<td>
<fmt:formatNumber value="${(r.p51_setvalue)}" maxFractionDigits="2" minIntegerDigits="2" var="mm"></fmt:formatNumber>
<c:out value="${(mm)}"/>
</td>
</tr>
<!-- For user_selection color name-- darkkhaki -->
<tr bgcolor="cornsilk">
<td><c:out value="${row.logtime}"></c:out></td>
<td>
<c:out value="${row.beam_current}"></c:out> </td>
<td>
<c:out value="${(row.beam_energy)}"/>
</td>
<td>
<fmt:formatNumber value="${(row.p51_readback)}" maxFractionDigits="2" minIntegerDigits="2" var="mm"></fmt:formatNumber>
<c:out value="${(row.p51_readback)}"/>
</td>
<td>
<fmt:formatNumber value="${(row.p51_setvalue)}" maxFractionDigits="2" minIntegerDigits="2" var="mm"></fmt:formatNumber>
<c:out value="${(mm)}"/>
</td>
</tr>
<tr>
<td>Deviation</td>
<jsp:include page="Mps_Hs_diff.jsp"></jsp:include>**Here I need to include another jsp as the cod ewas becoming large**
<c:set var="count" value="${count + 1}" scope="session" />
</c:forEach>
</c:forEach>
</table>
</body>
The another page where I need the values of r and row which are declared in this page is
<body>
<jsp:useBean id="ref" class="comp_Mps.Comp_Mps_hs"/>
<br>
<%
//Comaprision obj = new Comaprision();
String s_date= request.getParameter("startdate");
pageContext.setAttribute("s_date", s_date);
String e_date= request.getParameter("enddate");
pageContext.setAttribute("e_date", e_date);
ref.refarray_vac1(s_date,e_date);
ref.ClosestToMultiplesOfTen_User(s_date,e_date);
%>
<%
//Comaprision reference = new Comaprision();
String ref_name= request.getParameter("ref_logtime");
pageContext.setAttribute("ref_name", ref_name);
ref.FindClosestToMultiplesOfTen(ref_name);
ref.refernece(ref_name);
%>
<br><br><br>
<table width = "170%" border = "1" cellspacing="0" cellpadding="0">
<c:set var="row" value="${ref.refarray_vac1(param.startdate,param.enddate)}"></c:set>
<c:set var="r" value="${ref.refernece(param.ref_logtime)}"></c:set>
<tr>
<td scope="row" style="${r.beam_current-row.beam_current eq 0 ? 'background-color: lime':'background-color: pink'}">
<fmt:formatNumber value="${(r.beam_current-row.beam_current)}" maxFractionDigits="2" minIntegerDigits="2" var="mm"></fmt:formatNumber>
<c:out value="${mm}" ></c:out></td>
<td scope="row" style="${r.beam_energy-row.beam_energy eq 0 ? 'background-color: lime':'background-color: pink'}">
<fmt:formatNumber value="${(r.beam_energy-row.beam_energy)}" maxFractionDigits="2" minIntegerDigits="2" var="mm"></fmt:formatNumber>
<c:out value="${mm}" ></c:out></td>
<td style="${r.p51_readback-row.p51_readback eq 0 ? 'background-color: lime':'background-color: pink'}">
<fmt:formatNumber value="${((r.p51_readback-row.p51_readback))}" maxFractionDigits="2" minIntegerDigits="2" pattern="##.##" var="nn"></fmt:formatNumber>
<c:out value="${nn}"></c:out>
<fmt:formatNumber value="${(r.p51_readback-row.p51_readback)/r.p51_readback}" maxFractionDigits="2" minIntegerDigits="2" type="percent" var="mm"></fmt:formatNumber>
<c:out value="(${mm})" ></c:out></td>
But the first page is never called by the user, an another page is called on whose button click the first jsp is called.So the values in the page which I included are never processed as it is never called.
One option is to use the session scope in order to have your variable available in any JSP or servlet during the current session.
You can store your variables in the session scope:
HttpSession session = request.getSession();
String variableToPass = "hello";
session.setAttribute("variableToPass", variableToPass);
And, you can access them like this:
HttpSession session = request.getSession();
String variablePassed = session.getAttribute("variableToPass");
Hope it is helpful.

How to validate <aui:select> in a Liferay Form?

In View.jsp I created a form by using . there are some inputs and 3 select-box on it, actually I want to validate all of them. for inputs I used but I don't know how can I validate my
Actually I want to validate these three :
<aui:select id="birthday_day" name="birthday_day">
<aui:select id="birthday_month" name="birthday_month">
<aui:select id="birthday_year" name="birthday_year">
This is my view.jsp
<portlet:actionURL var="myUrl">
</portlet:actionURL>
<aui:form enctype="multipart/form-data" action="<%= myUrl %>" method="POST" name="fm">
<table border="0" bgcolor=#ccFDDEE>
<tr>
<td colspan="2" align="center"><b>Recruiment Form</b></td>
</tr>
<tr>
<td colspan="2" align="center"></td>
</tr>
<tr>
<td><b>First Name:<span>*</span></b></td>
<td>
<aui:input name="fname" type="text">
<aui:validator name="required"/>
</aui:input>
</td>
</tr>
<tr>
<td><b>Last Name:<span>*</span></b></td>
<td>
<aui:input name="lname" type="text">
<aui:validator name="required"/>
</aui:input>
</td>
</tr>
<tr>
<td><b>Father Name:<span>*</span></b></td>
<td>
<aui:input name="father_name" type="text">
<aui:validator name="required"/>
</aui:input>
</td>
</tr>
<tr>
<td><b>Birth Date:<span>*</span></b></td>
<td>
<aui:select id="birthday_day" name="<portlet:namespace/>birthday_day">
<aui:option value="0">روز</aui:option>
<%
for(int i=1;i<=31;i++) {
%>
<aui:option value="<%=i%>"><%=i%></aui:option>
<%
}
%>
</aui:select>
/
<aui:select id="birthday_month" name="birthday_month">
<aui:option value="0">ماه</aui:option>
<%
String[] monthBirthDay = {"فروردین","اردیبهشت","خرداد","تیر","مرداد","شهریور","مهر","آبان","آذر","دی","بهمن","اسفند"};
for(int j=0;j<monthBirthDay.length;j++) {
%>
<aui:option value="<%=j+1%>"><%=monthBirthDay[j]%></aui:option>
<%
}
%>
</aui:select>
/
<aui:select id="birthday_year" name="birthday_year">
<aui:option value="0">سال</aui:option>
<%
String[] yearBirthDay = {"1370","1369","1368","1367","1366","1365","1364"};
for(int j=0;j<yearBirthDay.length;j++) {
%>
<aui:option value="<%=yearBirthDay[j]%>"><%=yearBirthDay[j]%></aui:option>
<%
}
%>
</aui:select>
</td>
</tr>
</table>
</aui:form>
How can I solve this issue??????
Please guide me.
<aui:select showEmptyOption="true" name="select hospital name" required="true">
</aui:select>
THis may help you.
just assign an id to the aui:select tag
<aui:select inlineField="true" label="xxx" name="xxx" id="xxxId">
and then you can get the value with this (javascript + AUI)
var selectedVal = A.one('#<portlet:namespace/>xxxId').val();
with the selected value you can perform any kind of validation.

How to add values from checkbox to array?

I need your help.
I'm working on a jsp application.
The thing is that I have a form within a "select-option" then depending on the item I select from the "select option" I get a list with checkboxes, and I can get the checkboxes values in my servlet, but now what I try to do is to get does values and add them to an array. How can I do that?
JSP code:
//Select-option
<table>
<tr>
<td width="50%" style="text-align: left;">
<select class="selectSmall" id="a_selectCta" name="a_selectCta"
style="margin-bottom: 5px; width: 310px;">
<option value="">Seleccione un Cuentahabiente</option>
<%
for (Ctahabiente habiente : CtahabienteDAO.getCtahabientes()) {
if (ctahabiente != null && habiente.getIdCtahabiente().equalsIgnoreCase(ctahabiente.getIdCtahabiente())) {
%>
<option selected="selected" value="<%=ctahabiente.getIdCtahabiente()%>">
<%=ctahabiente.getIdCtahabiente() + " - " + ctahabiente.getDesCtahabiente()%></option>
<%
} else {
%>
<option value="<%=habiente.getIdCtahabiente()%>">
<%=habiente.getIdCtahabiente() + " - " + habiente.getDesCtahabiente()%></option>
<% } }
%>
</select>
</td>
</tr>
</table>
//List with checkboxes from select-option
<%
if (request.getAttribute("a_accion") != null) {
%>
<%
ctahabiente = null;
List<Directorio> listaDirectorio = (List<Directorio>)request.getAttribute("a_listaDirectorio");
ctahabiente =(Ctahabiente)request.getAttribute("a_ctahabiente");
%>
<table class="tableDirectorio" style="text-align: left;">
<tr>
<th width="5px">CheckBox</th>
<th width="5px">ID dir</th>
<th width="5px">ID cta</th>
</tr>
<%
if(listaDirectorio.size()>0){
itDirectorio = listaDirectorio.iterator();
boolean renglon=true; // renglon par
while(itDirectorio.hasNext()){
directorio = (Directorio) itDirectorio.next();
if(renglon){
%>
<tr>
<td style="background-color: #fff; text-align: center;"><input type="checkbox" id="checkCta" name="checkCta" value="<%=directorio.getIdDirectorio()%>" /></td>
<td style="background-color: #fff; text-align: center;"><%=directorio.getIdDirectorio()!= 0? directorio.getIdDirectorio():""%></td>
<td style="background-color: #fff; text-align: center;"><%=directorio.getIdCtahabiente()!= null? directorio.getIdCtahabiente():""%></td>
</tr>
<%
renglon=false;
}else{
%>
<tr>
<td style="background-color: #fff; text-align: center;"><input type="checkbox" id="checkCta" name="checkCta" value="<%=directorio.getIdDirectorio()%>" /></td>
<td style="background-color: #fff; text-align: center;"><%=directorio.getIdDirectorio()!= 0? directorio.getIdDirectorio():""%></td>
<td style="background-color: #fff; text-align: center;"><%=directorio.getIdCtahabiente()!= null? directorio.getIdCtahabiente():""%></td>
</tr>
<%
renglon=true;
}
}
%>
</table>
<%}%>

How to make the jsp page not to show the previous value set in session?

Below is my jsp file, once I process some value and display the value in jsp page. The value comes from servlet, but next time when I just enter the url the values are displayed which were there previously, so please suggest how to go about doing this?
The jsp code is :
<%# page contentType="text/html"%>
<%# page pageEncoding="UTF-8"%>
<%# page import="java.util.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%
Map<String, String> reportMap = new LinkedHashMap<String, String>();
if (session.getAttribute("leaveMap") != null) {
reportMap = (Map<String,String>) session.getAttribute("leaveMap");
}
String classname="",employeeid="",employeename="";
int style =0,sno=1;
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Comparing access-card Data with leave manager Data</title>
<link href="css/sling.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src='script/cal.js'></script>
<!-- Below imports for Blanket purpose-->
<script src='script/blanket.js'></script>
<script>
var _validFileExtensions = [".xls"];
function Validate(oForm) {
var arrInputs = oForm.getElementsByTagName("input");
var filename = document.getElementById("myFile");
if(filename.value.length ==0){
alert("Please select the file to upload");
return false;
}else{
for (var i = 0; i < arrInputs.length; i++) {
var oInput = arrInputs[i];
if (oInput.type == "file") {
var sFileName = oInput.value;
if (sFileName.length > 0) {
var blnValid = false;
for (var j = 0; j < _validFileExtensions.length; j++) {
var sCurExtension = _validFileExtensions[j];
if (sFileName.substr(sFileName.length - sCurExtension.length, sCurExtension.length).toLowerCase() == sCurExtension.toLowerCase()) {
blnValid = true;
break;
}
}
if (!blnValid) {
alert("Sorry, " + sFileName + " is invalid, allowed extensions are: " + _validFileExtensions.join(", "));
return false;
}
}
}
}
}
return true;
}
function isValidDate(element){
var elementValue = element.value;
var daysInMonth = DaysArray(12);
var pos1=elementValue.indexOf(dtCh)
var pos2=elementValue.indexOf(dtCh,pos1+1)
var strDay=elementValue.substring(0,pos1)
var strMonth=elementValue.substring(pos1+1,pos2)
var strYear=elementValue.substring(pos2+1)
strYr=strYear
if (strDay.charAt(0)=="0" && strDay.length>1)
strDay=strDay.substring(1)
if (strMonth.charAt(0)=="0" && strMonth.length>1)
strMonth=strMonth.substring(1)
for (var i = 1; i <= 3; i++) {
if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
}
month=parseInt(strMonth)
day=parseInt(strDay)
year=parseInt(strYr)
if(elementValue!="") {
if (pos1==-1 || pos2==-1){
return errorMessage("The date format should be : dd/mm/yyyy", element);
}
if (strMonth.length<1 || month<1 || month>12){
return errorMessage("Please enter a valid month", element);
}
if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
return errorMessage("Please enter a valid day", element);
}
if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
return errorMessage("Please enter a valid 4 digit year between "+minYear+" and "+maxYear, element);
}
if (elementValue.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(elementValue, dtCh))==false){
return errorMessage("Please enter a valid date", element);
}
}
return true;
}
function formatDate(textBoxObj) {
var elementValue = textBoxObj.value;
for (i=0; i<elementValue.length; i++){
if(((i==2)||(i==5))){}
else {
var c = elementValue.charAt(i);
if (((c < "0") || (c > "9"))){
alert("Only Numbers Are Allowed");
textBoxObj.value='';
return false;
}
}
}
if((elementValue.length==2)||(elementValue.length==5)){
textBoxObj.value=elementValue+'/';
}
return true;
}
function isValidDate(element){
var elementValue = element.value;
var daysInMonth = DaysArray(12);
var pos1=elementValue.indexOf(dtCh)
var pos2=elementValue.indexOf(dtCh,pos1+1)
var strDay=elementValue.substring(0,pos1)
var strMonth=elementValue.substring(pos1+1,pos2)
var strYear=elementValue.substring(pos2+1)
strYr=strYear
if (strDay.charAt(0)=="0" && strDay.length>1)
strDay=strDay.substring(1)
if (strMonth.charAt(0)=="0" && strMonth.length>1)
strMonth=strMonth.substring(1)
for (var i = 1; i <= 3; i++) {
if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
}
month=parseInt(strMonth)
day=parseInt(strDay)
year=parseInt(strYr)
if(elementValue!="") {
if (pos1==-1 || pos2==-1){
return errorMessage("The date format should be : dd/mm/yyyy", element);
}
if (strMonth.length<1 || month<1 || month>12){
return errorMessage("Please enter a valid month", element);
}
if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
return errorMessage("Please enter a valid day", element);
}
if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
return errorMessage("Please enter a valid 4 digit year between "+minYear+" and "+maxYear, element);
}
if (elementValue.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(elementValue, dtCh))==false){
return errorMessage("Please enter a valid date", element);
}
}
return true;
}
function DaysArray(n) {
for (var i = 1; i <= n; i++) {
this[i] = 31
if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
if (i==2) {this[i] = 29}
}
return this
}
<!-- Begin Script for progressbar
var progressEnd = 15; // set to number of progress <span>'s.
var progressColor = 'blue'; // set to progress bar color
var progressInterval = 1000; // set to time between updates (milli-seconds)
var progressAt = progressEnd;
var progressTimer;
function progress_clear() {
for (var i = 1; i <= progressEnd; i++) document.getElementById('progress'+i).style.backgroundColor = 'transparent';
progressAt = 0;
}
function progress_update() {
document.getElementById("statusmessage").style.display ="";
progressAt++;
if (progressAt > progressEnd) progress_clear();
else document.getElementById('progress'+progressAt).style.backgroundColor = progressColor;
progressTimer = setTimeout('progress_update()',progressInterval);
}
function progress_stop() {
document.getElementById("statusmessage").style.display ="none";
clearTimeout(progressTimer);
progress_clear();
}
// End for progressbar-->
function submitform(){
var oForm = document.getElementById('accesscarddata');
var startdate = document.getElementById("startdate").value;
var enddate = document.getElementById("enddate").value;
if(startdate == ""){
alert("Please select Start Date.");
return false;
}
if(enddate == ""){
alert("Please select End Date.");
return false;
}
if(Validate(oForm)){
progress_update();
document.forms["accesscarddata"].submit();
}
}
</script>
</head>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0"
marginheight="0" marginwidth="0" bgcolor="#FFFFFF">
<form name="accesscarddata" id="accesscarddata"
action="LeaveReportServlet" method="post"
enctype="multipart/form-data">
<table border="0" width="100%" cellspacing="0" cellpadding="0"
background="images/topbkg.gif">
<tr>
<td width="50%" valign="top"><img border="0"
src="images/logo.gif" width="145" height="66"></td>
<td width="50%" valign="top">
<p align="right">
<img border="0" src="images/topright.gif" width="315" height="66">
</td>
</tr>
</table>
<table border="0" width="100%" cellspacing="0" cellpadding="0"
background="img/blackline.gif">
<tr>
<td width="100%">
<p align="left">
<font color="#F0D8B8" face="Arial" size="2"><b>
slingemp | slingemp
| slingemp |
slingemp | slingemp
| slingemp | slingemp</b></font>
</td>
</tr>
</table>
<p align="center" style="margin-left: 20">
<font face="Arial" color="#000000" size="4">Attendance Process</font>
</p>
<div id="statusmessage" style="display:none">
<table align="center" >
<tr>
<td>
<div style="font-size:8pt;padding:2px;border:solid black 1px">
<span id="progress1"> </span>
<span id="progress2"> </span>
<span id="progress3"> </span>
<span id="progress4"> </span>
<span id="progress5"> </span>
<span id="progress6"> </span>
<span id="progress7"> </span>
<span id="progress8"> </span>
<span id="progress9"> </span>
<span id="progress10"> </span>
<span id="progress11"> </span>
<span id="progress12"> </span>
<span id="progress13"> </span>
<span id="progress14"> </span>
<span id="progress15"> </span>
</div>
</td>
</tr>
</table>
</div>
<p align="left" style="margin-left: 20">
<font face="Arial" size="2" color="#000000"> </font>
</p>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="25%" align="left"> </td>
<td width="1%" align="left"> </td>
<td width="64%" align="left">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr class="darkrow">
<td width="2%" align="left">*</td>
<td width="20%" align="left">Start Date</td>
<td width="58%" align="left"><input type="text"
name="startdate" id="startdate" maxlength="10"
onkeyup="formatDate(this)" onblur="isValidDate(this)" /> <img
src="images/calpicker.png" name="image" id="startdate"
onclick="scwShow(document.forms[0].startdate,event,'');return false;">
</td>
<td width="20%" align="left"> </td>
</tr>
<tr class="lightrow">
<td width="2%" align="left">*</td>
<td width="20%" align="left">End Date</td>
<td width="58%" align="left"><input type="text"
name="enddate" id="enddate" maxlength="10"
onkeyup="formatDate(this)" onblur="isValidDate(this)" /> <img
src="images/calpicker.png" name="image" id="startdate"
onclick="scwShow(document.forms[0].enddate,event,'');return false;">
</td>
<td width="20%" align="left"> </td>
</tr>
<tr class="darkrow">
<td width="2%" align="left">*</td>
<td width="20%" align="left">Select file</td>
<td width="58%" align="left"><input type="file"
name="myFile" id="myFile" /></td>
<td width="20%" align="left"> </td>
</tr>
<tr class="lightrow">
<td width="2%" align="left"> </td>
<td width="20%" align="left"> </td>
<td width="58%" align="left"><input type="button"
value="Process" onclick="submitform()" /></td>
<td width="20%" align="left"> </td>
</tr>
<%
if(reportMap.size()>0){ %>
<script>
progress_stop();
</script>
<tr class="lightrow">
<td width="2%" class="title_sub" align="center">S.No</td>
<td width="20%" class="title_sub" align="center">EmployeeID</td>
<td width="58%" class="title_sub" align="left">EmployeeName</td>
<td width="20%" class="title_sub" align="left">Action</td>
</tr>
<%
Iterator<Map.Entry<String, String>> entries = reportMap.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry<String, String> entry = entries.next();
if (style % 2 == 0) {
classname = "darkrow";
} else {
classname = "lightrow";
}
employeeid = entry.getKey();
employeename = entry.getValue();
%>
<tr class='<%=classname %>'>
<td width="2%" align="center"><%=sno %></td>
<td width="20%" align="center"><%=employeeid %></td>
<td width="58%" align="left"><%=employeename %></td>
<td width="20%" align="left"><a href="#" alt='<%=employeeid%>' title='<%=employeeid%>'>sendmail</a></td>
</tr>
<%
sno++;
style++;
}
}
%>
</table>
</td>
<td width="10%" align="right"> </td>
</tr>
</table>
<p align="left" style="margin-left: 20">
<font face="Arial" size="2" color="#000000"> </font>
</p>
<p align="left" style="margin-left: 20">
<font face="Arial" color="#000000" size="4"> </font>
</p>
<p align="left" style="margin-left: 20">
<font face="Arial" size="2" color="#000000"> </font>
</p>
<p align="left" style="margin-left: 20">
<font face="Arial" size="2" color="#000000"> </font>
</p>
<p align="left" style="margin-left: 20">
<font face="Arial" size="2" color="#000000"> </font>
</p>
<p align="center" style="margin-left: 20">
<font face="Arial" color="#000000" size="1">© COPYRIGHT 2012
ALL RIGHTS RESERVED SLINGMEDIA.COM</font>
</p>
<table border="0" width="100%" cellspacing="0" cellpadding="0"
background="images/botbkg.gif">
<tr>
<td width="100%"><img border="0" src="images/botbkg.gif"
width="48" height="12"></td>
</tr>
</table>
<div
style="text-align: center; font-family: Arial, Helvetica, Sans-Serif; font-size: 11px; color: #777;">
<a style="text-decoration: none; color: #777;"
href="#">Tutorials</a> | <a
style="text-decoration: none; color: #777;"
href="#">Codes</a> | <a
style="text-decoration: none; color: #777;"
href="#">Templates</a>
</div>
</form>
</body>
</html>
Use HttpSession.removeAttribute(String name).
Removes the object bound with the specified name from this session. If
the session does not have an object bound with the specified name,
this method does nothing.
if (session.getAttribute("leaveMap") != null) {
reportMap = (Map<String,String>) session.getAttribute("leaveMap");
session.removeAttribute("leaveMap");
}
Put data it in request scope [request attribute], or override with blank map in Servlet when you make new request
If you are using session then each time after iteratig data you will have to remove that object from session. but if you are using request then you do not need to remove data from request. each time you will get a new request object and new data set as well.

Categories

Resources