I want to generate tables in jsp page using data I got from Map in java. I use which use map value for define 'item'. But, The name of map value that I want to put on 'item' needs value from another map.
To be clear, here my jsp code;
<c:forEach var="wilayahProvinsi" items="${model.kodeKabupatenList}">
<div data-role="page" id="kode${wilayahProvinsi.ID2012}">
<div data-role="header" data-position="inline" data-fullscreen="true">
Back
<h1>${wilayahProvinsi.NAMA}</h1>
</div>
<div class="container">
<table id="example1" class="display nowrap" >
<thead>
<tr>
<th>Kode Komoditas</th>
<th>Jenis Barang</th>
<th>Nilai Konsumsi</th>
<th>Nilai Imputasi</th>
<th>Nilai Konsumsi Akhir</th>
<th>Persentase trhdp Total</th>
<th>Persentase trhdp Kelompok</th>
<th>Persentase trhdp Subkelompok</th>
<th>Edit</th>
<th>Delete</th>
</tr>
<tbody>
<!-- this is the problem -->
<c:forEach var="pekerjaanku" items="${model.pekerjaankuList$wilayahProvinsi.ID2012}">
<tr>
<td>${pekerjaanku.kode_komoditas}</td>
<td id="jenis_barang">${pekerjaanku.jenis_barang}</td>
<td style="text-align: right">${pekerjaanku.nilai_konsumsi}</td>
<td style="text-align: right">${pekerjaanku.nilai_imputasi}</td>
<td style="text-align: right">${pekerjaanku.nilai_konsumsi_akhir}</td>
<td style="text-align: right">${pekerjaanku.persentase_total}</td>
<td style="text-align: right">${pekerjaanku.persentase_kelompok}</td>
<td style="text-align: right">${pekerjaanku.persentase_subkelompok}</td>
<td><a href="kotaEdit?id=${pekerjaanku.kode_komoditas}" class="ui-btn ui-mini ui-corner-all ui-icon-edit
ui-btn-icon-left">Edit</a></td>
<td><a href="kotaDelete?id=${pekerjaanku.kode_komoditas}" class="ui-btn ui-mini ui-corner-all ui-icon-delete
ui-btn-icon-left" onclick="return confirm('Yakin ingin menghapus komoditas ${pekerjaanku.jenis_barang}?')">
Delete</a></td>
</tr>
</c:forEach>
</tbody>
</table>
<table>
<tr>
<td colspan="8">Tambah Komoditas Baru</td>
<td colspan="2">Download CSV</td>
</tr>
</table>
</div>
</div>
</c:forEach>
This is my Java code;
#RequestMapping("/jelajahPekerjaanKota")
public ModelAndView getPekerjaanKotaList() {
List<KodeKabupaten> kodeKabupatenList = usersService.getSpecifiedKodeKabupatenList();
Map<String, Object> model = new HashMap<String, Object>();
model.put("kodeKabupatenList", kodeKabupatenList);
for(KodeKabupaten kodeKabupaten : kodeKabupatenList){
model.put("pekerjaankuList" + kodeKabupaten.getID2012(), pekerjaankuService.getPekerjaankuList(kodeKabupaten.getID2012()));
}
return new ModelAndView("/provinsi/jelajahPekerjaanKota", "model", model);
}
To be clear, the objects in Map model is;
model.kodeKabupatenList which has attributes: NAMA, ID2012, PROV, and KAB
model.pekerjaankuList3171 which has attributes: kode_komoditas, jenis_barang, ...
model.pekerjaankuList3172 , the attributes are same with above
model.pekerjaankuList3173 , same with above
my problem is how to get all model.pekerjaankuList** in jsp with looping? I can not run this code in jsp;
<c:forEach var="pekerjaanku" items="${model.pekerjaankuList$wilayahProvinsi.ID2012}">
Related
Need some advice how should I retrieve a list of exhibits.
In my html template below, I only put one record of exhibit. If i were to put additional rows/records of exhibit, how do i go about mapping them to the controller.
HTML Template
<h3>Exhibit Details</h3>
<div class="table-responsive">
<table id="exhibitTable"
class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>Exhibit Type</th>
<th>Description</th>
<th>Marking</th>
<th>Remarks</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="form-group col-md-3">
<div class="cols-sm-10">
<select class="form-control selectpicker cols-md-3"
th:value="${exhibit.exhibitType}" id="exhibitType"
name="exhibitType" roleId="exhibitType">
<option value="">Select Type</option>
<option>Desktop</option>
<option>Laptop</option>
<option>Mobile Device</option>
<option>Portable Storage</option>
<option>Server</option>
<option>Video System</option>
<option>Save As</option>
<option>Others</option>
</select>
</div>
</div>
</td>
<td>
<div class="form-group col-md-3">
<input type="text" name="exhibitDescription"
id="exhibitDescription"
th:value="${exhibit.exhibitDescription}" />
</div>
</td>
<td>
<div class="form-group col-md-3">
<input type="text" name="exhibitMarking" id="exhibitMarking"
th:value="${exhibit.exhibitMarking}" />
</div>
</td>
<td><div class="form-group col-md-3">
<input type="text" name="exhibitRemarks" id="exhibitRemarks"
th:value="${exhibit.exhibitRemarks}" />
</div></td>
</tr>
</tbody>
</table>
</div>
Controller
#RequestMapping(value = "/register", method = RequestMethod.POST)
public String registerIncidentPost(#ModelAttribute("incident") Incident incident,
#ModelAttribute("exhibit") Exhibit exhibit, Principal principal) throws Exception {
long year = Calendar.getInstance().get(Calendar.YEAR);
incident.setIncidentYear(year + "");
Long refNo = incidentService.findMaxRefNoCurrentYear(year + "");
if (refNo == null)
refNo = (long) 1;
else
refNo += 1;
incident.setIncidentRefNo(refNo);
incident.setIncidentStatus(Incident.INCIDENT_REGISTERED);
incident.setIncidentOpeningTimestamp(new Date());
User user = userService.findByUsername(principal.getName());
incident.setIncidentCreatedBy(user);
incidentService.createIncident(incident);
exhibitService.createExhibit(exhibit);
return "redirect:/incident";
}
I've attempted to add the following to my template
<tr data-th-each="exhibit:${exhibitList}">
and the following to my controller
#ModelAttribute("exhibitList") ArrayList<Exhibit> exhibitList
but did not work.
Thanks in advance.
I can only assume this is vb.net since you didn't specify. You need to pass in the complete dataset to the page. Each item in the dataset will be one pre-loaded instance of the model. Then you can do a for each loop on the page itself and generate the html dynamically. Hope this helps.
I'm working in this project that opens a site pages fills the necesary fields get push the submit buttons and opens another window where some values are shown in a table, so far everything works ok but I don't know how to get the data from the table into my java program to save it in a file.
I'm working with Selenium WebDriver
this it's the code for my java program, I just need to get the info on the table:
import java.io.FileOutputStream;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.apache.commons.exec.util.StringUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;
public class Know_Your_Case_Status {
public void FillData(WebDriver driver) throws InterruptedException {
for (int i = 1; i < 12; i++) {
driver.get("http://cms.nic.in/ncdrcusersWeb/login.do?method=caseStatus");
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
//Select Radio Button for State Commission
driver.findElement(By.cssSelector("[id='UserType'][value='C']"))
.click();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
// Now Select State Assam
WebElement SelectState = driver.findElement(By.name("state_id"));
Select Sl = new Select(SelectState);
Sl.selectByVisibleText("Assam");
/**** Select From Date ******/
driver.findElement(By.cssSelector("img.ui-datepicker-trigger"))
.click();
// Select may Month
Select SelMonth = new Select(driver.findElement(By
.className("ui-datepicker-month")));
SelMonth.selectByValue("4");
// Select Year 2015
Select SelYear = new Select(driver.findElement(By.id("scrollyear")));
SelYear.selectByVisibleText("2015");
// Select date 1
driver.findElement(By.linkText("1")).click();
/**** Select To Date ******/
// driver.findElement(By.cssSelector("img.ui-datepicker-trigger")).click();
driver.findElement(By.xpath("(//img[#alt='...'])[2]")).click();
// Select Jan Month
Select SelToMonth = new Select(driver.findElement(By
.className("ui-datepicker-month")));
SelToMonth.selectByVisibleText("January");
// Select Year 2016
Select SelToYear = new Select(driver.findElement(By
.id("scrollyear")));
SelToYear.selectByVisibleText("2016");
// Select date 1
driver.findElement(By.linkText("8")).click();
Select SelCaseType = new Select(driver.findElement(By
.name("condition")));
SelCaseType.selectByVisibleText("CaseType");
Select Selval = new Select(driver.findElement(By.name("ctId")));
Selval.selectByIndex(i+1);
//Selval.selectByValue("8");
driver.findElement(By.name("advs")).click();
}
}
}
And the code source from the page I'm trying to get the info it's:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Query Report</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="./stylesheet/confoStyle.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="javascript/CommonCDRC.js"></script>
<script language="javaScript">
function doPrint()
{
tbHead.style.display = "none";
tbTail1.style.display = "none";
tbTail2.style.display = "none";
tbMenu.style.display = "none";
window.print();
tbHead.style.display = "";
tbTail1.style.display = "";
tbTail2.style.display = "";
tbMenu.style.display = "";
}
function submitForm()
{
var flgSubmit = 1;
var dtOfHearing = document.loginForm.dtOfHearing.value;
if(flgSubmit == 1)
{
document.loginForm.method.value = "loadSelectloginForCLhtml";
document.loginForm.submit();
}
else
return false;
}
function loadProceeding(caseid, fano)
{
document.loginForm.fano.value=fano;
document.loginForm.cid.value=caseid;
document.loginForm.action="ViewProceedingCS.jsp";
document.loginForm.submit();
}
</script>
</head>
<body bgcolor="#9cd3ed">
<form name="loginForm" method="post" action="/ncdrcusersWeb/login.do" onsubmit="return submitForm()">
<input type="hidden" name="method" value="ViewProceedingCS">
<input type="hidden" name="fano" value="">
<input type="hidden" name="case_id_in" value="">
<input type="hidden" name="dtOfHearing" value="">
<input type="hidden" name="courtId" value="">
<input type="hidden" name="cid" value="">
<input type="hidden" name="stateCode" value="5">
<input type="hidden" name="distCode" value="0">
<table class="baseContaner topGroup" width="100%" align="center">
<tr>
<td width="3%" class="rptsubnumhd">SN</td>
<td width="10%" class="rptsubnumhd">Case No</td>
<td width="17%" class="rptsubtxthd">Complainant</td>
<td width="17%" class="rptsubtxthd">Respondent</td>
<td width="18%" class="rptsubtxthd">Complainant-Advocate</td>
<td width="17%" class="rptsubtxthd">Respondent-Advocate</td>
<td width="8%" class="rptsubnumhd">Date of Filing</td>
<td width="10%" class="rptsubnumhd">
Date of Next Hearing
</td>
</tr>
<tr>
<td class="rptnumhval">1</td>
<td class="rptnumhval"><a class="help" href="javascript:loadProceeding('5/0/A/19/2015','A/19/2015' )">
A/19/2015 </a></td>
<td class="rpttxthval">Managing Director, The Assam Power Distribution Company Ltd.</td>
<td class="rpttxthval">Smti Khaleda Begum</td>
<td class="rpttxthval">Mr. P. Bhowmick</td>
<td class="rpttxthval"></td>
<td class="rptnumhval">15/05/2015</td>
<td class="rptnumhval">
19/05/2015
</td>
</tr>
<tr>
<td class="rptnumhval">2</td>
<td class="rptnumhval"><a class="help" href="javascript:loadProceeding('5/0/A/20/2015','A/20/2015' )">
A/20/2015 </a></td>
<td class="rpttxthval">The Chief Regional Manager, United India Insurance Company Ltd.</td>
<td class="rpttxthval">Mr. Dulu Dey</td>
<td class="rpttxthval">Mr. R. Goswami</td>
<td class="rpttxthval"></td>
<td class="rptnumhval">20/05/2015</td>
<td class="rptnumhval">
26/05/2015
</td>
</tr>
<tr>
<td class="rptnumhval">3</td>
<td class="rptnumhval"><a class="help" href="javascript:loadProceeding('5/0/A/21/2015','A/21/2015' )">
A/21/2015 </a></td>
<td class="rpttxthval">Dr. Vijay Nahata</td>
<td class="rpttxthval">Smti. Moushumi Nath</td>
<td class="rpttxthval">Mr. N. Sharma</td>
<td class="rpttxthval">Ms. D. Tamuli</td>
<td class="rptnumhval">05/06/2015</td>
<td class="rptnumhval">
11/09/2015
</td>
</tr>
<tr>
<td class="rptnumhval">4</td>
<td class="rptnumhval"><a class="help" href="javascript:loadProceeding('5/0/A/22/2015','A/22/2015' )">
A/22/2015 </a></td>
<td class="rpttxthval">Sri Biren Kalita</td>
<td class="rpttxthval">The Branch Manager, Ulubari Branch (CDO-II), Oriental Insurance Co. Ltd.</td>
<td class="rpttxthval">Mr. A. K. Gupta</td>
<td class="rpttxthval">Mr. S. Bhuyan</td>
<td class="rptnumhval">15/06/2015</td>
<td class="rptnumhval">
21/09/2015
</td>
</tr>
<tr>
<td class="rptnumhval">5</td>
<td class="rptnumhval"><a class="help" href="javascript:loadProceeding('5/0/A/23/2015','A/23/2015' )">
A/23/2015 </a></td>
<td class="rpttxthval">Smti. Sabita Roy</td>
<td class="rpttxthval">Managing Director, Birla Sun Life Insurance Co. Ltd.</td>
<td class="rpttxthval">Mr. N. N. Karmakar</td>
<td class="rpttxthval"></td>
<td class="rptnumhval">15/06/2015</td>
<td class="rptnumhval">
07/09/2015
</td>
</tr>
<tr>
<td class="rptnumhval">6</td>
<td class="rptnumhval"><a class="help" href="javascript:loadProceeding('5/0/A/24/2015','A/24/2015' )">
A/24/2015 </a></td>
<td class="rpttxthval">Branch Manager, Indian Overseas Bank</td>
<td class="rpttxthval">Mr. Padmeswar Baruati</td>
<td class="rpttxthval">Mr. V.K.Dewan</td>
<td class="rpttxthval"></td>
<td class="rptnumhval">24/06/2015</td>
<td class="rptnumhval">
17/09/2015
</td>
</tr>
<tr>
<td class="topHdMsg" colspan="8"><input type=button value="Back" onClick="history.go(-1)"></td>
</tr>
</table>
</form>
</body>
</html>
I was thinking that maybe a driver.findElement(By.tagName("table")).getText() may work but I'm getting all the data in one line, is it a way to separete the head and the lines ?
You should try as below :-
List<WebElement> rows = driver.findElement(By.tagName("table")).findElements(By.tagName("tr"));
for(WebElement row : rows)
{
List<WebElement> columns = row.findElements(By.tagName("td"));
for(WebElement column : columns)
{
String columnText = column.getText();
}
}
Hope it helps...:)
Im using JSTL tags and EL to get the values out of my database. I added a checkbox to the data table on the U.I for the functionality of deleting a record. The problem is the String[] in the servlet always comes out as null and I have no idea why. I even tried dummy data in the 'value' attribute on the checkbox element and the array was still null.
HTML
<div id="authorTable" >
<table style="text-align: center;">
<thead>
<th>Book ID</th>
<th>Title</th>
<th>Date Published</th>
<th>Author ID</th>
<th>Author First Name</th>
<th>Author Last Name</th>
<th>Delete</th>
</thead>
<tbody>
<c:forEach var="record" items="${bookRecordsResult}">
<tr>
<td>${record.bookID}</td>
<td>${record.title}</td>
<td>${record.datePublished}</td>
<td>${record.author.firstName}</td>
<td>${record.author.lastName}</td>
<td>${record.author.id}</td>
This Line ------> <td> <input type="checkbox" name="boxes" id="boxes" class="boxes" value="${record.bookID}" /> </td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
<div id="deleteContainer">
<form id="deleteForm" method="POST" action="bookAuthorControls">
<button type="submit" id="deleteButton" name="deleteButton" >Delete</button>
</form>
</div>
Java Servlet
String delete = request.getParameter("deleteButton");
if (delete != null) {
And This Line ----> String[] checkValues = request.getParameterValues("boxes");
try {
service.deleteRecords(Arrays.asList(checkValues));
bookRecords = service.getAllBookRecords();
request.setAttribute("bookRecordsResult", bookRecords);
} catch (SQLException | ClassNotFoundException | ParseException ex) {
request.setAttribute("error", ex.getLocalizedMessage());
}
}
Once again the String[] comes back null no matter what I try, any ideas?
The checkbox input elements are not contained in the form element which is submitted.
You need to wrap the form around all input elements:
<form id="deleteForm" method="POST" action="bookAuthorControls">
<div id="authorTable">
...
<td><input type="checkbox" name="boxes" id="boxes" class="boxes" value="${record.bookID}" /> </td>
...
</div>
<div id="deleteContainer">
<button type="submit" id="deleteButton" name="deleteButton" >Delete</button>
</div>
</form>
MY JSP PAGE:
<form action="manageparentexamforchildren.htm" class="form-horizontal form-bordered" >
<div class="form-body">
<div class="form-group">
<label class="control-label col-md-1"><spring:message code="label.parent.children"/></label>
<div class="col-md-3">
<select name="parent.children" class="form-control" id="children" required="true" >
<option value="">-<spring:message code="label.select"/>-</option>
<c:forEach items="${studentsOfThisParent}" var="student">
<option value="${student.id}">${student.firstName} ${student.lastName}</option>
</c:forEach>
</select>
</div>
</div>
</div>
<div class="form-actions fluid">
<div class="row">
<div class="col-md-12">
<div class="col-md-offset-3 col-md-9">
<button type="submit" class="btn blue"><i class="icon-ok"></i><spring:message code='button.search'/></button>
<button type="button" onclick="javascript:history.go(-1);" class="btn red default"><spring:message code='button.cancel'/></button>
</div>
</div>
</div>
</div>
</form>
<c:forEach items="${modelList}" var="examination">
<tr>
<td><b><spring:message code="label.examination.schoolexam"/></b>:<c:out value="${examination.schoolExam.name}" /></td>
</tr>
<table border="1" width="1000" height="200" class="table table-bordered table-hover">
<thead> <tr><th class="active"><spring:message code="label.examination.subjects"/></th><th class="active"><spring:message code="label.exam.Date"/></th><th class="active"><spring:message code="label.exam.maxmarks"/></th></tr></thead>
<tbody>
<c:forEach items="${examination.examinationSubjects}" var="examinationSubject" varStatus="status">
<tr>
<td class="success"><c:out value="${examinationSubject.subjects.name}" /></td>
<td class="success" ><c:out value="${examinationSubject.date}" /></td>
<td class="success"><c:out value="${examinationSubject.maxMarks}" /></td>
</tr>
</c:forEach>
</tbody>
</table>
</c:forEach>
MY CONTROLLER:
#RequestMapping(value="/manageparentexam.htm", method=RequestMethod.GET)
public String manageparentexam(ModelMap modelMap,HttpServletRequest request )
{
Parent parent = parentService.getParentById(getLoggedInUser().getId());
List <Student> studentsOfThisParent=parentService.getStudentsOfThisParent(getLoggedInUser().getId());
Student student=null;
student=parent.getStudentAdmission().get(0).getStudent();
modelMap.addAttribute("modelList",student.getStudentAdmission().getClasses().getExamination());
setupCreate(modelMap, request);
return "tileDefinition.manageparentexam-"+getNameSpace();
}
#RequestMapping(value="/manageparentexamforchildren.htm", method=RequestMethod.GET)
public void manageparentexamforchildren(ModelMap modelMap,HttpServletRequest request )
{
Long studentId=Long.valueOf(request.getParameter("parent.children"));
modelMap.addAttribute("modelList",studentService.getById(studentId).getStudentAdmission().getClasses().getExamination());
setupCreate(modelMap, request);
}
here my requirement is,when ever,i select a value in select box,then the table should get updated through ajax,here i am unable to bind the model list through ajax call . . .
What I would do is separate the table in another jsp. yourTable.jsp like this
<table border="1" width="1000" height="200" class="table table-bordered table-hover">
<thead> <tr><th class="active"><spring:message code="label.examination.subjects"/></th><th class="active"><spring:message code="label.exam.Date"/></th><th class="active"><spring:message code="label.exam.maxmarks"/></th></tr></thead>
<tbody>
<c:forEach items="${examination.examinationSubjects}" var="examinationSubject" varStatus="status">
<tr>
<td class="success"><c:out value="${examinationSubject.subjects.name}" /></td>
<td class="success" ><c:out value="${examinationSubject.date}" /></td>
<td class="success"><c:out value="${examinationSubject.maxMarks}" /></td>
</tr>
</c:forEach>
</tbody>
</table>
Then you include this jsp in your main mapge inside a div
<div id="yourTable">
<c:jsp include="yourTable.jsp/>
</div>
Then in your select you have to add a listener and when something has change you need to make a JQuery load lo reload the table rendering the table from the controller again with all the changes that you want
$('#yourTable').load("url of your controller where you will render yourTable.jsp");
And in the controller you will render yourTable.jsp and you will add in the ModelAndView object the examinationSubject
Does anyone has uses jsp debug helper page that can be dropped into any webapp or included from within another jsp page to view header, req and session attributes?
can you please share if possible ? It will be a great help for many
Drop pageDebugger.jsp in you webapp
Access the page directly or include from another jsp like, layout.jsp to show this details on every page
This page Lists following in a table
Request Parameters
Page scoped attributes and values
Request scoped attributes and values
Session scoped attributes and values
Application scoped attributes and values
Request headers
All Spring beans defined in the scope
Option to search for a resource on the classpath
Dependency on spring framework is optional remove it if you dont use
pageDebugger.jsp
<%#taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<style type="text/css">
td {
word-wrap: break-word;
}
</style>
</head>
<body>
<table width="100%" border="1" cellpadding="0" cellspacing="0"
style="table-layout: fixed;">
<colgroup>
<col width="500">
</colgroup>
<tr>
<th colspan="2">
<h3>attributes in $paramValues</h3>
</th>
</tr>
<c:forEach var="entry" items="${paramValues}">
<tr>
<td><c:out value="${entry.key}" /></td>
<td><c:forEach var="item" items="${entry.value}"
varStatus="status">
<pre><c:out value="${item}" /></pre>
<c:if test="${not status.last}">
<br />
</c:if>
</c:forEach></td>
</tr>
</c:forEach>
<tr>
<th colspan="2">
<h3>attributes in $requestScope</h3>
</th>
</tr>
<c:forEach var="entry" items="${requestScope}">
<tr>
<td><c:out value="${entry.key}" /></td>
<td><pre><c:out value="${entry.value}" /></pre></td>
</tr>
</c:forEach>
<tr>
<th colspan="2">
<h3>attributes in $sessionScope</h3>
</th>
</tr>
<c:forEach var="entry" items="${sessionScope}">
<tr>
<td><c:out value="${entry.key}" /></td>
<td><pre><c:out value="${entry.value}" /></pre></td>
</tr>
</c:forEach>
<tr>
<th colspan="2">
<h3>attributes in $pageScope</h3>
</th>
</tr>
<c:forEach var="entry" items="${pageScope}">
<tr>
<td><c:out value="${entry.key}" /></td>
<td><pre><c:out value="${entry.value}" /></pre></td>
</tr>
</c:forEach>
<tr>
<th colspan="2">
<h3>attributes in $headerValues</h3>
</th>
</tr>
<c:forEach var="entry" items="${headerValues}">
<tr>
<td><c:out value="${entry.key}" /></td>
<td><c:forEach var="item" items="${entry.value}"
varStatus="status">
<pre><c:out value="${item}" /></pre>
<c:if test="${not status.last}">
<br />
</c:if>
</c:forEach></td>
</tr>
</c:forEach>
<tr>
<th colspan="2">
<h3>attributes in $applicationScope</h3>
</th>
</tr>
<c:forEach var="entry" items="${applicationScope}">
<tr>
<td><c:out value="${entry.key}" /></td>
<td><pre><c:out value="${entry.value}" /></pre></td>
</tr>
</c:forEach>
<tr>
<th colspan="2">
<h3>System Properties</h3>
</th>
</tr>
<tr>
<th>Key</th>
<th>Value</th>
</tr>
<%#page import="java.util.Map"%>
<%#page import="java.util.Set"%>
<%#page import="java.util.Properties"%>
<%#page import="java.util.Arrays"%>
<%
Properties p = System.getProperties();
Set<Map.Entry<Object, Object>> set = p.entrySet();
for (Map.Entry<Object, Object> e : set) {
%>
<tr>
<td><%=e.getKey()%></td>
<td><%="".equals(e.getValue()) ? " " : e.getValue()%></td>
<%
}
%>
</tr>
<tr>
<th colspan="2">
<h3>Spring Beans</h3>
</th>
</tr>
<%#page import="org.springframework.web.context.WebApplicationContext"%>
<%#page
import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%#page import="org.springframework.core.io.Resource"%>
<%
try {
WebApplicationContext springContext = WebApplicationContextUtils
.getWebApplicationContext(config.getServletContext());
if (springContext != null) {
String[] beanNames = springContext.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
String className = springContext.getType(beanName)
.getName();
%>
<tr>
<td><%=beanName%></td>
<td><%=className%></td>
</tr>
<%
}
%>
<tr>
<th colspan="2">
<h3>Spring Resources</h3>
</th>
</tr>
<tr>
<th colspan="2">
<form><input name="resources" size="50"/></form>
</th>
</tr>
<%
String resourceNames = request.getParameter("resources");
if (resourceNames != null) {
Resource[] resources = springContext
.getResources(resourceNames);
for (Resource r : resources) {
%>
<tr>
<td><%=r.getFilename()%></td>
<td><%=r.getURI()%></td>
</tr>
<%
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
%>
</table>
</body>
</html>
Additionally if you have option to modify web.xml, have a look at these that can also be used to monitor / profile active http session attributes
http://code.google.com/p/sessionmon/
http://messadmin.sourceforge.net/
At work I have used JDeveloper to run an application in debug mode from the IDE. You can insert breakpoints into your .jsp and view all the debugging info. Although, I am not a big fan of jdeveloper, it is a nice feature of the IDE.