Software Project Management
Software Project Management
Software Project Management
RollNo:79
Q1. Design loan calculator using JSP which accepts Period ofTime (in years) and PrincipalLoan
amount. Display the interestpaid for the amount over the term of the loan for the followingtime
period and interest rate:
Code:
index.jsp:
<!DOCTYPE html>
<html>
<head>
<title>Loan Calculator</title>
</head>
<body>
<h1>Loan Calculator</h1>
<table border="1">
Saurabh kumar jayprakash pandey
RollNo:79
<tr>
<th>Time Period (Years)</th>
<th>Interest Rate</th>
<th>Interest Paid</th>
</tr>
<%
double interestRate; double
totalInterestPaid = 0; for (inti
= 1; i<= years; i++) {
if (i>= 1 &&i<= 7) { interestRate
= 0.0535;
} else if (i>= 8 &&i<= 15) { interestRate
= 0.055;
} else { interestRate
= 0.0575;
}
</body>
</html>
Output:
Saurabh kumar jayprakash pandey
RollNo:79
a. 1 to 7 year at 5.35%
Output:
b. 8 to 15 year at 5.5%
Output:
Saurabh kumar jayprakash pandey
RollNo:79
c. 16 to 30 year at 5.75%
Output:
Saurabh kumar jayprakash pandey
RollNo:79
Code:
Saurabh kumar jayprakash pandey
RollNo:79
CustomTag.java
package demo;
import java.util.Calendar; import
javax.servlet.jsp.JspException; import
javax.servlet.jsp.JspWriter; import
javax.servlet.jsp.tagext.TagSupport; public
class CustomTag extends TagSupport{
Customtaglib.tld
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>simple</short-name>
<uri>http://tomcat.apache.org/example-taglib</uri>
<tag>
<name>today</name>
<tag-class>demo.CustomTag</tag-class>
</tag>
</taglib>
Index.jsp
Output:
Saurabh kumar jayprakash pandey
RollNo:79
Code:
Database code:
Login.jsp:
</head>
<body>
<%
String I_name=request.getParameter("name");
String I_Password=request.getParameter("pass");
Class.forName("com.mysql.cj.jdbc.Driver"); Connection
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/student","root","root");
String query="select * from student100 where s_name=? and s_password=?";
PreparedStatementps=conn.prepareStatement(query); ps.setString(1,I_name);
ps.setString(2,I_Password); ResultSetrs=ps.executeQuery(); if (rs.next())
{ session.setAttribute("name",I_name);
response.sendRedirect("Dashboard.jsp");
} else {
response.sendRedirect("Login.jsp");
}
%>
</body> </html>
Dasboard.jsp:
<html>
<body>
<%
if(session.getAttribute("name")!=null){
%>
<h1 style="text-align:center">
Welcome to my page "<%=session.getAttribute("name")%>"
</h1>
<br>
<a style="display: block;text-align:center" href="Logout.jsp">
Click here to Logout</a>
<%
}else{
response.sendRedirect("Login.jsp"); }
%>
</body></html>
Logout.jsp:
<% session.invalidate();
%>
<p>you have been successfully logged out!</p>
</body>
</body>
</html> Output:
Saurabh
Q4. Write a jsp Program to add, delete and display the records from the
StudentMaster (Roll no. , Name , Semester, Course) Table (Using JST5L Tags)
Database :
Saurabh kumar jayprakash pandey
RollNo:79
StudentMaster.jsp
<!DOCTYPE html>
<html>
<head>
<head> <style>
table, th, td {
border: 1px solid black;
}
</style>
<meta charset="UTF-8">
<title>Insert title here</title>
</head> <body>
<sql:setDataSourcevar="db" driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/STUDENT" user="root" password="root" />
<sql:updatedataSource="${db}" var="insertRow">
UPDATE StudentMaster SET Semester="SEM 1" where RollNo=2; </sql:update>
<sql:querydataSource="${db}" var="rs">
select * from StudentMaster; </sql:query>
Saurabh kumar jayprakash pandey
RollNo:79
<form action="DeleteStudent.jsp">
<table>
<tr>
<td>ID</td>
<td>Name</td>
<td>Semester</td> <td>Course</td>
</tr>
<c:forEachvar="table" items="${rs.rows}">
<tr>
<td><c:out value="${table.rollno}"></c:out></td>
<td><c:out value="${table.name}"></c:out></td>
<td><c:out value="${table.semester}"></c:out></td>
<td><c:out value="${table.course}"></c:out></td>
<td><button type="submit" name="delete"
value="${table.rollno}">Delete</button></td>
</tr>
</c:forEach>
</table>
</form>
</body>
</html>
DeleteStudent.jsp
Web.xml
OutPut: