|
IGNOU > IGNOU Assignments > MCA > MCA 2009 Assignments >Laboratory Course
IGNOU MCA Assignments
Question 2 Write a JSP Program, which displays a web page containing two web links. When one click on Link for getting current date and time it goes to a JSP page which display current date and time and by clicking on link for schedule of your practical sessions of MCSL 54 another JSP page will open to show the schedule.
Ans:
Lab2.jsp
<html>
<head></head>
<body>
<div align="center"><a href="date.jsp">Link for getting current date and
time</a></div>
<div align="center"><a href="schedule.jsp">Schedule of your practical sessions
of MCSL 54
</a></div>
</body>
</html>
date.jsp
<%@ page language="java" import="java.util.*" errorPage="" %>
<%
Date dt = new Date();
out.println("Date is:"+dt);
%>
Question 3 Write a program using JDBC and JSP to display the names and addresses of all those MCA students at your study centre who have completed/submitted their theory assignments of all the courses of IV Semester.
Ans:
Assignments.jsp
<%@ page language="java" import="java.sql.*" errorPage="" %>
<%@ page language="java" import="java.util.*" errorPage="" %>
<%
Connection conn = null;
Statement st = null;
try
{
%>
<html>
<head>
<title>SpyNetHub.com - Assignments</title>
<link href="../styles/Main.css" rel="stylesheet" type="text/css">
</head>
<body topmargin="0" leftmargin="0" rightmargin="0">
<table border="0" cellpadding="0" cellspacing="0" width="750" align="center">
<tr>
<td align="center">ENo</td>
<td align="center">Name</td>
<td align="center">Subject</td>
<td align="center">Address</td>
</tr>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn =
DriverManager.getConnection("jdbc:mysql://localhost/spynethub?user=root&pas
sword=spynethub");
st = conn.createStatement();
ResultSet profile = st.executeQuery("SELECT Eno, Name, Subject,
Address from assignments");
while(profile.next())
{
String eno = profile.getString(1);
String name = profile.getString(2);
String subject = profile.getString(3);
String address = profile.getString(5);
%>
<tr>
<td><%= eno %></td>
<td><%= name %></td>
<td><%= subject %></td>
<td><%= address %></td>
</tr>
<%
}
profile.close();
}catch(Exception e){out.println("Error:"+e);
%>
  
|