I am new to thymeleaf and am trying to create an html table where a boolean decides whether the text will be pass or fail in some of the columns.
SmokeTest.passOrFailArray is an array of booleans.
Right now the smokeTest.name is showing up in the column but the passed or failed text is not showing up at all.
Here is my thymeleaf/html code
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Smoke Tests</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<table border="1" style="width:300px">
<tr>
<td>Test Name</td>
<td th:each="testsThatRan : ${testsThatRan}"
th:text="${testsThatRan}">Tests</td>
</tr>
<th:block th:each="smokeTest : ${smokeTests}">
<tr>
<td th:text="${smokeTest.name}">A Smoke Test'</td>
<th:block th:each="smokeTest.passOrFailArray : ${smokeTest.passOrFailArray}">
<td th:if="${smokeTest.passOrFailArray} == true" th:text="Passed"></td>
<td th:if="${smokeTest.passOrFailArray} == false" th:text="failed"></td>
</th:block>
</tr>
</th:block>
</table>
</body>
</html>
Here is the class that im using as a variable in thymeleaf
public testers() throws IOException {
localPath = "/Users/dansbacher14/Documents/workspace/OBI_nightly_test/src/OBI_ci_scripts_tests";
remotePath = "ssh://git#stash.ops.aol.com:2022/obi/obi_ci_scripts.git";
localRepo = new FileRepository(localPath + "/.git");
pathToSmoke = "BPS/GPS/GATHR/SMOKE";
pathToODirectory = "test-results";
git = new Git(localRepo);
}
public static <C> void testClone() throws IOException, InvalidRemoteException, TransportException, GitAPIException
{
Git.cloneRepository().setURI(remotePath).setDirectory(new File(localPath)).call();
}
//____________SETTERS AND GETTERS __________________________________________________________________________________
public void setName(String name)
{
jmxName = name;
}
public String getName()
{
return jmxName;
}
public boolean[] getPassOrFailArray()
{
return passOrFailArray;
}
public String getLocalPath()
{
return localPath;
}
}
This is how the source code is presented by the browser.
<!DOCTYPE HTML>
<html>
<head>
<title>Smoke Tests</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<table border="1" style="width:300px">
<tr>
<td>Test Name</td>
<td>OBI01</td>
<td>DEV</td>
</tr>
<tr>
<td>authAmtTesting.jmx</td>
</tr>
<tr>
<td>authTesting.jmx</td>
</tr>
<tr>
<td>CC_Crypto.jmx</td>
</tr>
<tr>
<td>ci_address.jmx</td>
</tr>
<tr>
<td>ci_cardtype_negative.jmx</td>
</tr>
<tr>
<td>ci_cardtype_positive.jmx</td>
</tr>
<tr>
<td>promoSmokeTst.jmx</td>
</tr>
<tr>
<td>tokenizedPayment.jmx</td>
</tr>
</table>
</body>
</html>
Is it possible to do something like this in thymeleaf? If so how could I make this work? Thanks
This code works
<th:block th:each="pf : ${smokeTest.passOrFailArray}">
<td th:if="${pf} == true" th:text="Passed"></td>
<td th:if="${pf} == false" th:text="failed"></td>
</th:block>
the problem is that i was naming my variable in the each loop incorrectly. The name cannot have a period in it.
Related
I have a django admin action function that display Transactions and loops through as many as queryset selected that will be rendered in html page, and converts the html to pdf.
I want at the pdf that each transaction object fit in A4, not to have another transaction object in same page. here is code..
def report_pdf(self, request, queryset):
if request.user.is_superuser:
transaction = queryset
else:
transaction = queryset.filter(user=request.user)
template_path = "single-pdf.html"
context = {"transactions": transaction}
template = get_template(template_path)
html = template.render(context)
file = open('test.pdf', "w+b")
pisaStatus = pisa.CreatePDF(html.encode('utf-8'), dest=file,
encoding='utf-8')
file.seek(0)
pdf = file.read()
file.close()
return HttpResponse(pdf, 'application/pdf')
and here is my html
{% load staticfiles %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Report</title>
<style>
</style>
</head>
{% for transaction in transactions %}
<body>
<div class="container">
{% if transaction.complete %}
<table class="tg" >
<thead>
<tr>
<th class="tg-4rlv">Report for Tenant</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tg-c6of" CHP Reference</span></td>
<td class="tg-c6of">{{transaction.chp_reference}}</td>
</tr>
<tr>
<td class="tg-c6of"> Rent Effective From(dd/mm/yyyy)</td>
<td class="tg-c6of">{{transaction.rent_effective_date}}</td>
</tr>
<tr>
<td class="tg-c6of"> CRA Fortnightly Rates valid for 6 months from</td>
<td class="tg-c6of">{{transaction.cra_rate_from}}</td>
</tr>
<tr>
<td class="tg-l8qj">Market Rent of the property :</td>
<td class="tg-c6of">{{transaction.property_market_rent}}</td>
</tr>
<tr>
<td class="tg-l8qj" >Number of Family Group(s) :</td>
<td class="tg-c6of">{{transaction.number_of_groups}}</td>
</tr>
</div>
</body>
</html>
I'm new to thymeleaf and am trying to make a simple table using an array and an each loop.
My code looks like this:
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Smoke Tests</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<table border="1" style="width:300px">
<tr>
<td>Test Name</td>
</tr>
<tr th:each="smokeTest : ${smokeTests}">
<td>
th:text="${smokeTest.name}">A Smoke Test'
</td>
</tr>
</table>
</body>
</html>
Basically my problem is that I can't run the loop as <td>s within <tr>s. Is there any way that this code could work?
You must put th:text as an attribute of a tag, so
<tr th:each="smokeTest : ${smokeTests}">
<td th:text="${smokeTest.name}">A Smoke Test'</td>
</tr>
should run.
Simple solution which comes to mind first:
<th:block th:each="smokeTest : ${smokeTests}">
<tr>
<td th:text="${smokeTest.name}">A Smoke Test'</td>
</tr>
</th:block>
Details: http://www.thymeleaf.org/whatsnew21.html#bloc
Although, it's late answer.
It's work more specifically, like
<tr th:each="smokeTest : ${smokeTests}">
<td><p th:text="${smokeTest.name}"></p></td>
</tr>
Hi i am writing a spring mvc hibernate annotation application there i have 2 tables "team" and another table "players".Here i am using one-to-one mapping and mysql database.In players table i am keeping player records like name,years active etc.The "team" table contains two entries teamid(primary key)and teamname.
The "players" table contains the foreign key teamid.Here when i try to delete a teamname without deleting all its references in players table i am getting error message
HTTP Status 500 - Request processing failed; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute update query
so when i delete all the references ,then there is no error.So how can i find all the refrences before deleting.I am interested in showing an alert message using javascript which warns to delete all references.I know how to create simple alert message in javascript,but here i have to show the alert only if there is a reference to foreign key.And i want to know is there any alternate way to delete the foriegn key reference without affecting the "players" table.
AddTeam.java
#Entity
#Table(name="Team")
public class AddTeam {
#Id
#Column(name="teamId")
private Integer teamId;
#Column(name="teamName")
private String teamName;
public Integer getTeamId() {
return teamId;
}
public void setTeamId(Integer teamId) {
this.teamId = teamId;
}
public String getTeamName() {
return teamName;
}
public void setTeamName(String teamName) {
this.teamName = teamName;
}
}
Player.java
#Entity
#Table(name="playerdata")
public class Player implements Serializable {
private static final long serialVersionUID = -723583058586873479L;
/**
*
*/
#Id
#Column(name="playerid")
private Integer playerId;
#Column(name="playername")
private String playerName;
#Column(name="yearsactive")
private Integer yearsActive;
#Column(name="country")
private Integer Country;
#OneToOne
#JoinColumn(name="teamId")
private AddTeam teams;
public Integer getPlayerId(){
return playerId;
}
public void setPlayerId(Integer playerId){
this.playerId=playerId;
}
public String getPlayerName(){
return playerName;
}
public void setPlayerName(String playerName){
this.playerName=playerName;
}
public String getCountry(){
return Country;
}
public void setCountry(String Country){
this.Country=Country;
}
public Integer getyearsActive(){
return yearsActive;
}
public void setyearsActive(Integer yearsActive){
this.yearsActive=yearsActive;
}
public AddTeam getTeams() {
return teams;
}
public void setTeams(AddTeam teams) {
this.teams = teams;
}
}
and this is the query used in playerDaoImplementation.java class
#Override
public void deleteResource(int playerid) {
// TODO Auto-generated method stub
sessionfactory.getCurrentSession().createQuery("DELETE FROM Resource WHERE playerid=" +playerid).executeUpdate();
}
Query used to delete in AddteamDaoImplementation.java
#Override
public void deleteTeams(int teamid) {
// TODO Auto-generated method stub
sessiofactory.getCurrentSession().createQuery("DELETE FROM AddTeam WHERE teamid="+teamid).executeUpdate();
}
deletefunction in PlayerController.java
#RequestMapping(value="/deletePlayer",method=RequestMethod.GET)
public ModelAndView deletePlayerDetails(#ModelAttribute("command") Player player,
BindingResult result){
playerService.deletePlayer(player.getPlayerId());
Map<String, Object> model = new HashMap<String, Object>();
model.put("playerkey", playerService.listPlayer());
model.put("teamKey", addteamService.listTeams());
return new ModelAndView("EditPlayer",model);
}
Team.jsp
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%#taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!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>Players Manager</title>
<center>
<h2>Add Team Details</h2>
<form:form method="POST" action="Team.html">
<table>
<tr>
<td><form:label path="teamId">Team ID:</form:label></td>
<td><form:input path="teamId" id="demo" value="${team.teamId}"/></td>
</tr>
<tr>
<td><form:label path="teamName">Team Name:</form:label></td>
<td><form:input path="teamName" value="${team.teamName}"/></td>
</tr>
<tr>
<tr>
<td> </td>
<td><input type="submit" value="SAVE"/></td>
</tr>
</table>
</form:form>
<br/>
<c:if test="${!empty teamKey}">
<table align="center" border="1">
<tr>
<th>Category ID</th>
<th>Category Name</th>
<th>Options</th>
</tr>
<c:forEach items="${teamKey}" var="team">
<tr>
<td><c:out value="${team.teamId}"/></td>
<td><c:out value="${team.teamName}"/></td>
<td align="center">Edit |
Delete</td>
</tr>
</c:forEach>
</table>
</c:if>
<h2>Adding Publication</h2>
</center>
</body>
</html>
EditPlayer.jsp
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%#taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!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>Resource Manager</title>
</head>
<body>
<center>
<h2>Add Players</h2>
<form:form method="POST" action="save.html">
<table>
<tr>
<td><form:label path="playerId">Player Id</form:label></td>
<td><form:input path="playerId" value= "${player.playerId }"/></td>
</tr>
<tr>
<td><form:label path="playerName">Name</form:label></td>
<td><form:input path="playerName" value="${player.playerName }"/></td>
</tr>
<tr>
<td><form:label path="YearsActive">Experience</form:label></td>
<td><form:input path="YearsActive" value="${player.YearsActive }"/></td>
</tr>
<tr>
<td><form:label path="Country">Date of Join</form:label></td>
<td><form:input path="Country" value="${player.Country }"/></td>
</tr>
<tr>
<td>
<form:label path="teams.teamId">Team Name</form:label>
</td>
<td>
<form:select path="teams.teamId" cssStyle="width: 150px;">
<option value="-1">Select a type</option>
<c:forEach items="${teamKey}" var="teams">
<option value="${teams.teamId}">${teams.teamName}</option>
</c:forEach>
</form:select>
</td>
</tr>
<tr>
<tr>
<td colspan="2"><input type="submit"value="Submit"></td>
</tr>
</table>
</form:form>
<br/>
<c:if test="${!empty playerkey}">
<table align="center" border="1">
<tr>
<th>Player ID</th>
<th>Player Name</th>
<th>YearsActive</th>
<th>Country</th>
</tr>
<c:forEach items="${playerkey}" var="player">
<tr>
<td><c:out value="${player.playerId}"/></td>
<td><c:out value="${player.playerName }"/></td>
<td><c:out value="${player.YearsActive}"/></td>
<td><c:out value="${player.Country}"/></td>
<td align="center">Edit | Delete</td>
</tr>
</c:forEach>
</table>
</c:if>
<h2>Adding Team</h2>
</center>
</body>
</html>
please help.
thanks in advance
For your use case your database modelling ( if you have schema already defined) or entity modelling( in case you are generating schema from your entity model) is incorrect. The foreign key should be on the AddTeam table pointing to the primary key of Player. In terms of entity mappings, the OneToOne should be on the AddTeam.
Hi i am writing a spring mvc hibernate annotation application there i have 2 tables "team" and another table "players".Here i am using one-to-one mapping and mysql database.In players table i am keeping player records like name,years active etc.The "team" table contains two entries teamid(primary key)and teamname.
The "players" table contains the foreign key teamid.Here when i try to delete a teamname without deleting all its references in players table i am getting error message
HTTP Status 500 - Request processing failed; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute update query
so when i delete all the references ,then there is no error.So how can i find all the refrences before deleting.I am interested in showing an alert message using javascript which warns to delete all references.I know how to create simple alert message in javascript,but here i have to show the alert only if there is a reference to foreign key.And i want to know is there any alternate way to delete the foriegn key reference without affecting the "players" table.
Team.java
#Entity
#Table(name="Team")
public class AddTeam {
#Id
#Column(name="teamId")
private Integer teamId;
#Column(name="teamName")
private String teamName;
public Integer getTeamId() {
return teamId;
}
public void setTeamId(Integer teamId) {
this.teamId = teamId;
}
public String getTeamName() {
return teamName;
}
public void setTeamName(String teamName) {
this.teamName = teamName;
}
}
Player.java
#Entity
#Table(name="playerdata")
public class Player implements Serializable {
private static final long serialVersionUID = -723583058586873479L;
/**
*
*/
#Id
#Column(name="playerid")
private Integer playerId;
#Column(name="playername")
private String playerName;
#Column(name="yearsactive")
private Integer yearsActive;
#Column(name="country")
private Integer Country;
#OneToOne
#JoinColumn(name="teamId")
private AddTeam teams;
public Integer getPlayerId(){
return playerId;
}
public void setPlayerId(Integer playerId){
this.playerId=playerId;
}
public String getPlayerName(){
return playerName;
}
public void setPlayerName(String playerName){
this.playerName=playerName;
}
public String getCountry(){
return Country;
}
public void setCountry(String Country){
this.Country=Country;
}
public Integer getyearsActive(){
return yearsActive;
}
public void setyearsActive(Integer yearsActive){
this.yearsActive=yearsActive;
}
public AddTeam getTeams() {
return teams;
}
public void setTeams(AddTeam teams) {
this.teams = teams;
}
}
and this is the query used in playerDaoImplementation.java class
#Override
public void deleteResource(int playerid) {
// TODO Auto-generated method stub
sessionfactory.getCurrentSession().createQuery("DELETE FROM Resource WHERE playerid=" +playerid).executeUpdate();
}
Query used to delete in AddteamDaoImplementation.java
#Override
public void deleteTeams(int teamid) {
// TODO Auto-generated method stub
sessiofactory.getCurrentSession().createQuery("DELETE FROM AddTeam WHERE teamid="+teamid).executeUpdate();
}
deletefunction in PlayerController.java
#RequestMapping(value="/deletePlayer",method=RequestMethod.GET)
public ModelAndView deletePlayerDetails(#ModelAttribute("command") Player player,
BindingResult result){
playerService.deletePlayer(player.getPlayerId());
Map<String, Object> model = new HashMap<String, Object>();
model.put("playerkey", playerService.listPlayer());
model.put("teamKey", addteamService.listTeams());
return new ModelAndView("EditPlayer",model);
}
Team.jsp
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%#taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!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>Players Manager</title>
<center>
<h2>Add Team Details</h2>
<form:form method="POST" action="Team.html">
<table>
<tr>
<td><form:label path="teamId">Team ID:</form:label></td>
<td><form:input path="teamId" id="demo" value="${team.teamId}"/></td>
</tr>
<tr>
<td><form:label path="teamName">Team Name:</form:label></td>
<td><form:input path="teamName" value="${team.teamName}"/></td>
</tr>
<tr>
<tr>
<td> </td>
<td><input type="submit" value="SAVE"/></td>
</tr>
</table>
</form:form>
<br/>
<c:if test="${!empty teamKey}">
<table align="center" border="1">
<tr>
<th>Category ID</th>
<th>Category Name</th>
<th>Options</th>
</tr>
<c:forEach items="${teamKey}" var="team">
<tr>
<td><c:out value="${team.teamId}"/></td>
<td><c:out value="${team.teamName}"/></td>
<td align="center">Edit |
Delete</td>
</tr>
</c:forEach>
</table>
</c:if>
<h2>Adding Publication</h2>
</center>
</body>
</html>
EditPlayer.jsp
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%#taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!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>Resource Manager</title>
</head>
<body>
<center>
<h2>Add Players</h2>
<form:form method="POST" action="save.html">
<table>
<tr>
<td><form:label path="playerId">Player Id</form:label></td>
<td><form:input path="playerId" value= "${player.playerId }"/></td>
</tr>
<tr>
<td><form:label path="playerName">Name</form:label></td>
<td><form:input path="playerName" value="${player.playerName }"/></td>
</tr>
<tr>
<td><form:label path="YearsActive">Experience</form:label></td>
<td><form:input path="YearsActive" value="${player.YearsActive }"/></td>
</tr>
<tr>
<td><form:label path="Country">Date of Join</form:label></td>
<td><form:input path="Country" value="${player.Country }"/></td>
</tr>
<tr>
<td>
<form:label path="teams.teamId">Team Name</form:label>
</td>
<td>
<form:select path="teams.teamId" cssStyle="width: 150px;">
<option value="-1">Select a type</option>
<c:forEach items="${teamKey}" var="teams">
<option value="${teams.teamId}">${teams.teamName}</option>
</c:forEach>
</form:select>
</td>
</tr>
<tr>
<tr>
<td colspan="2"><input type="submit"value="Submit"></td>
</tr>
</table>
</form:form>
<br/>
<c:if test="${!empty playerkey}">
<table align="center" border="1">
<tr>
<th>Player ID</th>
<th>Player Name</th>
<th>YearsActive</th>
<th>Country</th>
</tr>
<c:forEach items="${playerkey}" var="player">
<tr>
<td><c:out value="${player.playerId}"/></td>
<td><c:out value="${player.playerName }"/></td>
<td><c:out value="${player.YearsActive}"/></td>
<td><c:out value="${player.Country}"/></td>
<td align="center">Edit | Delete</td>
</tr>
</c:forEach>
</table>
</c:if>
<h2>Adding Team</h2>
</center>
</body>
</html>
please help.
thanks in advance
You have to do select query for teamId in players table to find players and in DB you can put cascade delete in players Table so it will delete players when you delete Team.
I have created a table in oracle which consist of college_names, student_name,regno and result belong to particular college and college_ids of each and every college and date on which the data has been stored...
Now I want to give college_id and date and i want all the student name with their result and regno in a table like structure in a browser I have written one html page for giving college_id and date and one jsp page for retrieving different fields from database but its not working..here is my code for both the pages..
this is my html page
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org /TR/html4/loose.dtd">
<html>
<head>
<script>
function check()
{
var a=result.college_id.value;
var b=result.date.value;
if(a==""|| b=="")
{
alert("fill the fields")
}
else
{
result.action="result.jsp";
result.method="post";
result.submit();
}
}
</script>
</head>
<body bgcolor="#cc99ff">
<form name="result">
<center>
<table>
<tr>
<td>college_id:</td>
<td><input type="text" name="college_id"></td>
</tr>
<tr>
<td>date:</td>
<td><input type="text" name="date"></td>
</tr>
<tr>
<td>
<input type="Button" value="Submit" onClick="check()">
</td>
</tr>
</table>
</center>
</body>
</html>
Now here is my jsp page for retrieving multiple rows...
<html>
<body background="main_BG.jpg">
<%#page language="java"%>
<%#page import="java.sql.*,java.util.*"%>
<%!
Connection con;
PreparedStatement ps;
ResultSet rs;
String college_id;
String college_name;
String regno;
String student_name;
String result;
String date;
%>
<%
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:#localhost:1521:orcl","pro","pro
");
college_id=request.getParameter("college_id");
date=request.getParameter("date");
ps=con.prepareStatement("select * from add_result where college_id=? and date=?");
ps.setString(1,college_id);
ps.setString(6,date);
rs=ps.executeQuery();
while(rs.next())
{
college_name=rs.getString(2);
regno=rs.getString(3);
student_name=rs.getString(4);
result=rs.getString(5);
}
else
{
out.println("no data found");
}
}
catch(Exception e)
{
out.println("<center><b><font color=lightblue>some error occured...please try again</font></b></center>");
out.println("<br><br><a href='result.html'><center><b><font color=lightblue>click here to return..</font></b></center>");
}
%>
<center>
<font color=lightblue>
<b>
Information of student with college_id [<%=college_id%>]:
</b>
</font>
</center>
<p style="position:absolute;left:100;top:100">
<table border="2" width="100%">
<th style="color:yellow">
college_name
</th>
<th style="color:yellow">
regno
</th>
<th style="color:yellow">
student_name
</th>
<th style="color:yellow">
result
</th>
<tr>
<td style="color:lightgreen" align="center"><%=college_name%></td>
<td style="color:lightgreen" align="center"><%=regno%></td>
<td style="color:lightgreen" align="center"><%=student_name%></td>
<td style="color:lightgreen" align="center"><%=result%></td>
</tr>
</table>
</p>
</body>
</html>
<%
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:#localhost:1521:orcl","pro","pro ");
college_id=request.getParameter("college_id");
date=request.getParameter("date");
String sql = "select * from add_result where college_id=? and date=?";
ps=con.prepareStatement(sql);
ps.setString(1,college_id);
//ps.setString(6,date);
ps.setString(2,date);
System.out.println("Sql: " + sql);
rs=ps.executeQuery();
// process resultset below
}
catch(Exception e)
{
out.println("<center><b><font color=lightblue>some error occured...please try again</font></b></center>");
out.println("<br><br><a href='result.html'><center><b><font color=lightblue>click here to return..</font></b></center>");
}
%>
<center>
<font color=lightblue>
<b>
Information of student with college_id [<%=college_id%>]:
</b>
</font>
</center>
<p style="position:absolute;left:100;top:100">
<table border="2" width="100%">
<th style="color:yellow">
college_name
</th>
<th style="color:yellow">
regno
</th>
<th style="color:yellow">
student_name
</th>
<th style="color:yellow">
result
</th>
<%
if(rs!=null){
while(rs.next())
{
college_name=rs.getString(2);
regno=rs.getString(3);
student_name=rs.getString(4);
result=rs.getString(5);
%>
<tr>
<td style="color:lightgreen" align="center"><%=college_name%></td>
<td style="color:lightgreen" align="center"><%=regno%></td>
<td style="color:lightgreen" align="center"><%=student_name%></td>
<td style="color:lightgreen" align="center"><%=result%></td>
</tr>
<%
} // result set loop ends here
}else{
%>
<tr>
<td colspan="4" style="color:red" align="center">No Data Found</td>
</tr>
<%
} //if condition ends here
%>