Module 2 Assignments Java (MCA)
Module 2 Assignments Java (MCA)
1. Create a Telephone directory using JSP and store all the information within a database,
so that later could be retrieved as per the requirement. Make your own assumptions. (same
as Q 3 )
2. Write a JSP page to display the Registration form (Make your own assumptions)
3. Write a JSP program to add, delete and display the records from StudentMaster
(RollNo, Name, Semester, Course) table.
4. Design loan calculator using JSP which accepts Period of Time (in years) and Principal
Loan Amount. Display the payment amount for each loan and then list the loan balance and
interest paid for each payment over the term of the loan for the following time period and
interest rate:
a. 1 to 7 year at 5.35%
b. 8 to 15 year at 5.5%
c. 16 to 30 year at 5.75%
Assignment No 6 : based on web application development using JSP
5. Write a program using JSP that displays a webpage consisting Application form
for change of Study Center which can be filled by any student who wants to
change his/ her study center. Make necessary assumptions
6. Write a JSP program to add, delete and display the records from
StudentMaster (RollNo, Name, Semester, Course) table.
7. Write a JSP program that demonstrates the use of JSP declaration, scriptlet,
directives, expression, header and footer.
How to install JSTL? The absolute uri: http://java.sun.com/jstl/core cannot be resolved
● https://stackoverflow.com/questions/4928271/how-to-install-jstl-the-absolute-uri-http-ja
va-sun-com-jstl-core-cannot-be-r/4928309#4928309
● https://stackoverflow.com/tags/jstl/info
How to resolve HTTP 500 internal server error in Eclipse?
To solve the problem add the jar file to the WEB-INF/lib folder of the project
Design loan calculator using JSP which accepts Period of Time (in years) and
Principal Loan amount. Display the interest paid for the amount over the term of
the loan for the following time period and interest rate:
a. 1 to 7 year at 5.35%
b. 8 to 15 year at 5.5%
c. 16 to 30 year at 5.75%
Validate user for data in database (mysql) and redirect to dashboard where
user can logout.
MySQL installation
Steps : https://youtu.be/2c2fUOgZMm
Installation of MySQL :
https://drive.google.com/file/d/1aU05EP5kwbo5AkAluuqt2jyFYwdjnmbh/view?
usp=sharing
Download Jar file :(Download and extract jar file from following)
https://drive.google.com/drive/folders/1azcHvOPhdwXGS57QgJlQyRlpqEzei7N
q?usp=sharing
Login.jsp
<fieldset style="width: 30%; border: 3px solid black">
<legend>Login</legend>
<form action="LoginUser.jsp" method="post">
<table>
<tr>
<td>User Name:</td>
<td><input type="text" name="name" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="pass" /></td>
</tr>
<tr>
<td><input type="submit" value="Login" /></td>
</tr>
</table>
</form>
</fieldset>
LoginUser.jsp
<%@ page import="java.sql.*"%>
<%
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/mydb","root","root");
String query="select * from student where s_name=? and s_password=?";
PreparedStatement ps=conn.prepareStatement(query);
ps.setString(1,I_name);
ps.setString(2,I_Password);
ResultSet rs=ps.executeQuery();
if (rs.next())
{
session.setAttribute("name",I_name);
response.sendRedirect("Dashboard.jsp");
}
else
{
response.sendRedirect("Login.jsp");
}
%>
Dashboard.jsp
<%
if (session.getAttribute("name") != null) {
%>
<h1 style="text-align: center">
Welcome "<%=session.getAttribute("name")%>" </h1>
<br>
<a style="display: block; text-align: right" href="Logout.jsp">
Click here to Logout</a>
<%
} else {
response.sendRedirect("Login.jsp");
}
%>
Logout.jsp
<body>
</body>
Right Click on
WEB-INF ⇒ New ⇒ File ⇒ MyLibrary.tld
MyLibrary.tld
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>2.0</jsp-version>
<description>This is a demonstration tag library</description>
<tag>
<name>date</name>
<tag-class>com.mytagpackage.MyTagHandler</tag-class>
</tag>
</taglib>
Step 3 : Create New JSP page
CREATE TABLE StudentMaster ( RollNo INT NOT NULL, Name VARCHAR (20)
NOT NULL, Semester VARCHAR (20) NOT NULL, Course VARCHAR (25),
PRIMARY KEY (RollNo) );
Create JSP pages:
● StudentMaster.jsp
● DeleteStudent.jsp
Add following jar file inside classpath and lib folder for
JSTL and Database : (JSTL library and Mysql connector
jar both are required)
https://drive.google.com/drive/folders/1azcHvOPhdwXGS57
QgJlQyRlpqEzei7Nq?usp=sharing
https://tomcat.apache.org/download-taglibs.cgi
Drive link :
● StudentMaster.jsp
<head>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
Inside body tag:
<sql:update dataSource="${db}">
</sql:update>
<c:redirect url="StudentMaster.jsp"></c:redirect>
Self assignment Write a JSP page to display the Registration form (Make your own
assumptions)