| <%@ page language="java" import="java.util.*"
contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<jsp:useBean id="company" class="com.cv.jsp.dot.operator.Employee">
<%
company.setId(Integer.parseInt(request.getParameter("id")));
company.setName(request.getParameter("name"));
%>
</jsp:useBean>
<%!Map<String, Map<String, String>> mappedObject = new HashMap<String, Map<String, String>>();
Map<String, String> map = new HashMap<String, String>();
List<String> cities = new ArrayList<String>();
List<String> nums = new ArrayList<String>();%>
<%
nums.add("0");
nums.add("1");
nums.add("2");
nums.add("3");
request.setAttribute("numbers", nums);
cities.add("HYD");
cities.add("USA");
cities.add("UK");
map.put("name", "Chandra");
map.put("city", "KPHP");
map.put("desig", "Engg");
map.put("HYD","Rupee");
map.put("USA","Dollar");
map.put("UK","Pound");
mappedObject.put("name", map);
request.setAttribute("mappedObj", mappedObject);
request.setAttribute("map", map);
request.setAttribute("cities", cities);
%>
<%!List<Integer> list = new ArrayList<Integer>();%>
<%
list.add(10);
list.add(100);
list.add(1000);
request.setAttribute("list", list);
%>
<%!String[] songsList = { "zero", "one", "two", "three" };%>
<%
request.setAttribute("songsList", songsList);
%>
<fieldset>
<legend>Result page...</legend>
<table align="center">
<br>
<br>
<tr>
<td><label>Name of employee from jsp:getProperty : : </label></td>
<td><font color="RED"><jsp:getProperty property="name"
name="company" /></font></td>
</tr>
<tr>
<td><label>Id of employee from jsp:getProperty : : </label></td>
<td><font color="RED"> <jsp:getProperty property="id"
name="company" /></font></td>
</tr>
<tr>
<td><label>Map of Map object acessing : : </label></td>
<td><font color="RED"> ${mappedObj["name"]} </font></td>
</tr>
<tr>
<td><label>Accessing the key called 'name' from map : :
</label></td>
<td><font color="RED"> ${map.name} </font></td>
</tr>
<tr>
<td><label>Accessing the key called 'name' from map 2
way : : </label></td>
<td><font color="RED"> ${map["name"]}</font></td>
</tr>
<tr>
<td><label>I am from {map[cities[0]]} : : </label></td>
<td><font color="RED"> ${map[cities[0]]}</font></td>
</tr>
<tr>
<td><label>I am from {map[cities[1]]}: : </label></td>
<td><font color="RED"> ${map[cities[1]]}</font></td>
</tr>
<tr>
<td><label>I am from {map[cities[2]]}: : </label></td>
<td><font color="RED">${map[cities[2]]}</font></td>
</tr>
<tr>
<td><label>I am from {cities[numbers[0]]}: : </label></td>
<td><font color="RED">${cities[numbers[0]]}</font></td>
</tr>
<tr>
<td><label>I am from {cities[numbers[0]+1]} : : </label></td>
<td><font color="RED">${cities[numbers[0]+1]}</font></td>
</tr>
<tr>
<td><label>I am from {cities[numbers["2"]]} : : </label></td>
<td><font color="RED">${cities[numbers["2"]]}</font></td>
</tr>
<tr>
<td><label>I am from {cities[numbers[numbers[1]]]} : :
</label></td>
<td><font color="RED">${cities[numbers[numbers[1]]]}</font></td>
</tr>
<tr>
<td><label>I am from {list[0]} : : </label></td>
<td><font color="RED"> ${list[0]}</font></td>
</tr>
<tr>
<td><label>I am from {list["1"]} : : </label></td>
<td><font color="RED"> ${list["1"]}</font></td>
</tr>
<tr>
<td><label>I am from {list[2]} : : </label></td>
<td><font color="RED">${list[2]}</font></td>
</tr>
<tr>
<td><label>I am from {songsList[0]} : : </label></td>
<td><font color="RED">${songsList[0]}</font></td>
</tr>
<tr>
<td><label>I am from {songsList["1"]} : : </label></td>
<td><font color="RED"> ${songsList["1"]}</font></td>
</tr>
<tr>
<td><label>I am from {songsList[2]} : : </label></td>
<td><font color="RED">${songsList[2]}</font></td>
</tr>
</table>
</fieldset>
</body>
</html>
|
No comments:
Post a Comment