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>
<%}%>
Related
I need a little help with Java here. How do I fill e.g. table cell 4,3, and 16 by clicking a Button ?
So If I click my Button I want the predefined tablecells to be red. Sorry but I'm a beginner.
Hope someone can help me :-)
cheers and stay healthy
table td {
border: 1px solid black;
padding: 30px;
}
.fill {
background-color: red;
}
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
</tr>
<tr>
<td>9</td>
<td>10</td>
<td>12</td>
<td>12</td>
</tr>
<tr>
<td>13</td>
<td>14</td>
<td>15</td>
<td>16</td>
</tr>
</table>
<button onclick="">CLICK</button>
Given your question, I am going to assume that it is related to Javascript and not Java. If not and you really needed a helping hand in Java, I'm sorry for the misunderstanding!
So, first I think you need to add some ids to your tablecells, so we can identify them later.
Then you call a small Javascript function when you click the button with just a parameter, an array of the tablecells' ids that you want to color.
That function, for each id that you provide, will add the class fill.
I hope that answers your question, sorry for my English and my technique, I'm a kind of beginner too!
function fill_cells($cells) {
$cells.forEach(e => document.getElementById(e).classList.add('fill'));
}
table td {
border: 1px solid black;
padding: 30px;
}
.fill {
background-color: red;
}
<table>
<tr>
<td id="1">1</td>
<td id="2">2</td>
<td id="3">3</td>
<td id="4">4</td>
</tr>
<tr>
<td id="5">5</td>
<td id="6">6</td>
<td id="7">7</td>
<td id="8">8</td>
</tr>
<tr>
<td id="9">9</td>
<td id="10">10</td>
<td id="11">12</td>
<td id="12">12</td>
</tr>
<tr>
<td id="13">13</td>
<td id="14">14</td>
<td id="15">15</td>
<td id="16">16</td>
</tr>
</table>
<button onclick="fill_cells([4, 3, 16])">CLICK</button>
I'm not an expert either on this, but you could use JQuery to change css, see https://api.jquery.com/css/
function makeRed() {
$(".selected").css("background-color", "red");
}
table td {
border: 1 px solid black;
padding: 30 px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
</tr>
<tr>
<td class='selected'>9</td>
<td>10</td>
<td>12</td>
<td>12</td>
</tr>
<tr>
<td>13</td>
<td>14</td>
<td>15</td>
<td>16</td>
</tr>
</table>
<button onclick=makeRed()>CLICK</button>
I have a form with some inputs; each input returns a list of data which is displayed in a table in another html page. Each input have a table to display it's data. My task is to do not display the data if the input is not entered by the user.
Here is my code
<!-- Country Table-->
<%for(int i = 0; i < countryList.length;i++){
if(countryList.length == 0)
break;
%>
<div class="box" align="center">
<table name="tab" align="center" class="gridtable">
<thead >
<tr>
<th style="width: 50%" scope="col">Entity Watch List Key</th>
<th style="width: 50%" scope="col">Watch List Name</th>
</tr>
</thead>
<tbody>
<tr>
<td style="width: 50%"><%out.println((String) (countryList[i].getEntityWatchListKey()));%></td>
<td style="width: 50%"><%out.println((String) (countryList[i].getEntityName()));%></td>
</tr>
</tbody>
</table>
</div>
<%}%>
I am using break to go out of the loop to do not display the table, is that true ?
You can use this condition before the for loop,
if(countryList.length != 0)
or
if(countryList.length > 0)
and then you need not use the break condition,
Furthermore the for loop you have currently defined will not work because if the length of the array is 0 then this condition i < countryList.length will become 0<0 and it will fail,so your for loop won't even be entered.So your current if condition if(countryList.length == 0) will not be accessed.
Please modify your code
<div class="box" align="center">
<table name="tab" align="center" class="gridtable">
<thead >
<tr>
<th style="width: 50%" scope="col">Entity Watch List Key</th>
<th style="width: 50%" scope="col">Watch List Name</th>
</tr>
</thead>
<tbody>
<%for(int i = 0; i < countryList.length;i++){
if(countryList.length > 0) %>
<tr>
<td style="width: 50%"><%out.println((String) (countryList[i].getEntityWatchListKey()));%></td>
<td style="width: 50%"><%out.println((String) (countryList[i].getEntityName()));%></td>
</tr>
<%}%>
</tbody>
</table>
</div>
For a good practice you have to repeat the row not the table.
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;">
   Zauzetost stola:   <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;">
   Zauzetost stola:   <b>Zauzet </b>
</p>
</td>
</tr>
<tr>
<td style="border: 0;">
<p style="font-size: 15px;">
   Datum rezervacije:   <b> <span id="datumRez"> ${rezSto.datumRezervacije} </span> </b>
</p>
</td>
</tr>
<tr>
<td style="border: 0;">
<p style="font-size: 15px;">
   Trajanje rezervacije:   <b> ${rezSto.rezervacijaTrajanje} </b>
</p>
</td>
</tr>
<tr>
<td style="border: 0;">
<p style="font-size: 15px;">
   Korisnici:<b>   ${rezSto.gost.korisnikIme}   ${rezSto.gost.korisnikPrezime}   </b><!-- <c:forEach items="${rezSto.pozvaniPrijatelji}" var="pri"> ,<b> ${pri.gost.korisnikIme}   ${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.
i want to test the sorting in collapse group?? it's possible or not? Please share that how to do it. blow pic have two group 1) Branch:Clifton and 2) Branch: Holsopple.(columns are sorted by clicking on Columns heading(Contact, Type etc)).below mentioned code work where group is not exist but fail where is group on page.
when i compare the gettext in java it shows result false while sorting of the text on the page is correct,because my java code gets the text in whole column and sorting is on collapse group. I wanna write the code which verify the sorting of columns on collapse group base.
HTML is here:
<tbody>
<tr class="rgGroupHeader">
<td class="rgGroupCol">
<td colspan="9">
<p>Branch: Clifton</p>
</td>
</tr>
<td class="rgGroupCol"/>
<td style="display:none;" title="289855">289855</td>
<td style="display:none;" title="31">31</td>
<td style="display:none;"/>
<td style="display:none;" title="12">12</td>
<td style="display:none;" title="6">6</td>
<td class="col_priority">
<td title="10/24/2013">10/24/2013</td>
<td class="col_status">
<div id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl19_divStatus" class="status_active" title="Open - Active"/>
</td>
<td>
<td>
<td>
<td title="Nawaz, S (10/22/2013)">
<td class="col_manager_instruction">
<td class="col_expiry" title="N/A">N/A</td>
</tr>
<tr id="ctl00_CPHPageContents_dtgLeads_ctl00__8" class="rgRow">
<td class="rgGroupCol"/>
<td style="display:none;" title="289856">289856</td>
<td style="display:none;" title="31">31</td>
<td style="display:none;"/>
<td style="display:none;" title="11">11</td>
<td style="display:none;" title="6">6</td>
<td class="col_priority">
<td title="10/24/2013">10/24/2013</td>
<td class="col_status">
<td>
<td>
<td>
<td title="Nawaz, S (10/22/2013)">
<td class="col_manager_instruction">
<td class="col_expiry" title="11/25/2013">11/25/2013</td>
</tr>
<tr class="rgGroupHeader">
<td class="rgGroupCol">
<input id="ctl00_CPHPageContents_dtgLeads_ctl00__35__0" class="rgCollapse" type="button" title="Collapse group" onclick="$find("ctl00_CPHPageContents_dtgLeads_ctl00")._toggleGroupsExpand(this, event); return false;__doPostBack('ctl00$CPHPageContents$dtgLeads$ctl00$ctl37$ctl00','')" value=" " name="ctl00$CPHPageContents$dtgLeads$ctl00$ctl37$ctl00"/>
</td>
<td colspan="9">
<p>Branch: Holsopple</p>
</td>
</tr>
<tr id="ctl00_CPHPageContents_dtgLeads_ctl00__16" class="rgRow">
<td class="rgGroupCol"/>
<td style="display:none;" title="289768">289768</td>
<td style="display:none;" title="2">2</td>
<td style="display:none;"/>
<td style="display:none;" title="12">12</td>
<td style="display:none;" title="4">4</td>
<td class="col_priority">
<div id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_divPriority" class="priority_high" title="High"/>
</td>
<td title="06/27/2013">06/27/2013</td>
<td class="col_status">
<div id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_divStatus" class="status_active" title="Open - Active"/>
</td>
<td>
<div id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_divInner">
<a id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_hlnkContact" href="/Leads/Research/289768">John Ross</a>
<input id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_hdfContactID" type="hidden" value="174120" name="ctl00$CPHPageContents$dtgLeads$ctl00$ctl38$hdfContactID"/>
<div id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_divContactCardControl" class="pos_r"/>
</div>
</td>
<td>
<div class="lead_type">
<a id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_lnkType" class="lead_type_link" href="/Leads/Research/289768" title="Maturing CD 100">Maturing CD 100</a>
<a id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_lnkDownArrow" class="down_arrow" onclick="showCloseTransferLayer('ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_CloseTransferLayer')" href="javascript:;"/>
<span class="pos_r">
<div id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_CloseTransferLayer">
<a id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_lnkCloseLead" onclick="return ShowPopupForm('/Forms/Popups/CloseLead.aspx?LeadID=289768','WindowCloseLead');" href="javascript:;">Cancel Lead</a>
<a id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_lnkTransferLead" onclick="return ShowPopupForm('/Forms/Popups/TransferLead.aspx?LeadID=289768','WindowTransferLead');" href="javascript:;">Transfer Lead</a>
</div>
</span>
</div>
</td>
<td>
<div id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_divAssignedTo">
<div id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_ddlAssignedTo" class="RadComboBox RadComboBox_Default assigned_to_combo" style="width:160px;">
<table style="border-width: 0px; border-collapse: collapse;" summary="combobox">
<tbody>
<tr class="rcbReadOnly">
<td class="rcbInputCell rcbInputCellLeft" style="width:100%;">
<input id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_ddlAssignedTo_Input" class="rcbInput radPreventDecorate" type="text" readonly="readonly" value="Org, T" name="ctl00$CPHPageContents$dtgLeads$ctl00$ctl38$ddlAssignedTo" autocomplete="off"/>
</td>
<td class="rcbArrowCell rcbArrowCellRight">
<a id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_ddlAssignedTo_Arrow" style="overflow: hidden;display: block;position: relative;outline: none;">select</a>
</td>
</tr>
</tbody>
</table>
<div class="rcbSlide" style="z-index:6000;">
<div id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_ddlAssignedTo_DropDown" class="RadComboBoxDropDown RadComboBoxDropDown_Default " style="display:none;">
<div class="rcbScroll rcbWidth" style="width:100%;">
<ul class="rcbList" style="list-style:none;margin:0;padding:0;zoom:1;">
<li class="rcbItem">Ghaffar, A</li>
<li class="rcbItem">Keller, K</li>
<li class="rcbItem">Nawaz, S</li>
<li class="rcbItem">Org, 1</li>
<li class="rcbItem">Org, T</li>
</ul>
</div>
</div>
</div>
<input id="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_ddlAssignedTo_ClientState" type="hidden" name="ctl00_CPHPageContents_dtgLeads_ctl00_ctl38_ddlAssignedTo_ClientState" autocomplete="off"/>
</div>
</div>
</td>
<td/>
<td class="col_manager_instruction">
<td class="col_expiry" title="N/A">N/A</td>
</tr>
</tbody>
Java Code:
List<String> displayedNames = new ArrayList<String>();
List<String> SortedNames = new ArrayList<String>();
String getData;
Thread.sleep(thread);
for(int i=0;i<tableType.size();i++)
{
getData=tableType.get(i).getText();
System.out.println(getData);
displayedNames.add(getData);
SortedNames.add(getData);
}
System.out.println(displayedNames);
Thread.sleep(thread);
List<String> sortingOperation = displayedNames;
Thread.sleep(thread);
Collections.sort(sortingOperation);
Thread.sleep(thread);
Assert.assertEquals(SortedNames, sortingOperation);
List<String> displayedNames = new ArrayList<String>();
List<String> SortedNames = new ArrayList<String>();
Thread.sleep(10000);
WebElementtableType=action.driver.findElement(By.xpath("//[#id='table_1_core_table_content']/tbody/tr"));
Thread.sleep(10000);
List<WebElement>rowElmt=tableType.findElements(By.xpath("//tr/td[5]"));
String getData;
Thread.sleep(5000);
for(int i=2;i<rowElmt.size();i++)
{
getData=rowElmt.get(i).getText();
displayedNames.add(getData);
SortedNames.add(getData);
}
System.out.println(displayedNames);
Thread.sleep(5000);
List<String> sortingOperation = displayedNames;
Collections.sort(sortingOperation);
Assert.assertEquals(SortedNames, sortingOperation);
}
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.