Mcsl
-
054
PART
-
I: MCS
-
051 (Advanced Internet Technologies)
QUESTION
-
1
: Develop a web page using Servlet which ask for your name and address
and print a message “ Welcome! Mr./Miss. Your Name on this web page” and show the
current date and time on the
top of web page.
Soltion:
Imporr javax.servlet.*;
Imporr javax.servlet.http.*;
Imporr java.io.*;
Imporr java.utill.Date;
Public clasas HelloServlet extends HttpSe
rvlet
{
Public void (HttpServletRequest, request, HttpServlet response)
Throws IoException, ServletException
{
Response.setContentType(“Text/html”);
PrintWriter out = response.getWriter();
Out.println (“<Htmt>”);
Out.println (“<Body>”);
Out.println (“
Enter your name<input type=”text” name=”a”>”);
Out.println (“Address <input type =”text” name =”b>”);
String n = request.getParameter (“a”);
Out.println (“Welcome! Mr./Miss” +a);
Out.println (“new.java.util.Date(
));
}
}
QUESTION
-
2
:
Write a JSP Program
, which displays a web page containing two web links
one for your profiling and other for the schedule of theory of practical classes of your
Batch. When one click on link for getting your profile it goes to a JSP page which display
your personal profile
and by clicking on link for classes schedule another JSP page
will
open to show the schedule
Solution
:
Menu.Jsp
<html>
<body>
<form action =”profile.jsp” method = “post”>
<input type = “submit” value=”PROFILE”>
</form>
<form action=”schedule.jsp method=
”post”>
<input type=submit” value=”SCHEDULE”>
</form>
</body>
</html>
</html>
Profile.jsp
<html>
<body>
<h1> MY PROFILE </h1>
NAME
VINITA AGARWAL
ADDRESS
A
-
16/F NEW DELHI
SCHOOL
MCS.SBM., NEW DELHI
UNIVERSITY
I.G.N.O.U
QULIFICATION
B.C.A, Pursuing M.C.A
Skills
C, C++, JAVA
Ph. No.
9811836816
</Body>
</html>
Schedule. Jsp
<html>
<body>
<h1> Schedulen OF MCA(5) THEORY <h1>
<b> MCS
-
051 </B>
Monday
Tuesday
Saturday
<b> MCS
-
052 </b>
Sunday
<b> MCS
-
053 </b>
Saturday
Sunday
</body
>
<html>
QUESTION
-
3
:
Write a program using JDBC and JSP to display the computer books
available in your Study Centres Library. Provide suitable options for issue/return of the
books and searching and pupation in the library database.
Solution
:
SO.jsp
<html>
<b
o
dy>
<
form action = “Book.jsp” method = “post”>
<input type =”submit” value = “BookInfo”>
</form>
<form action = “Issue.jsp” method = “post”>
<input type =”submit” value = “
Issue
”>
</form>
<form action = “Search.jsp” method = “post”>
<input type =”submit”
value = “Search”>
</form>
<form action = “Retun.jsp
” method
= “post”>
<input type =”submit” value = “Return”>
</form>
</body>
</html>
Book.jsp
<% @ language=”java” import= “java.sql.*”, “java.io>
<html>
<body>
<%
Class.forName (“C
om.mywqyl.jd
bc.Driver”);
Connection con=DriverManager.getConection(“jdbc : mysql : // localhost / institute”, “root”,
“1234”);
Statement st = con.createStatement( );
ResultSet rs = st.executeQuery(“Select * from Liabrary where subject =”computer”);
Int i
= 0;
While (rs.next(i) = = True)
{
Out.println(rs.getString (i)”);
}
%>
</body>
</html>
Issue.jsp
<html>
<body>
<form action =”issued.jsp” method = “post”>
ID NO. <input type = “text” name=”
b”>
<%
<input type = “submit” value= “IssueBook”>
</for
m>
</body>
</html>
QUESTION
-
4.
Create an XML document for
student’s
record at
your Study
Centre.
Solution:
<?xml version=1.0 ?>
<student Records>
<student Record>
<Name> VINITA AGGARWAL</Name>
<PROGRAMME> MCA </PROGRAMME>
<E
-
No> 063501077</E
-
No>
<Addre
ss> g
-
14/B, Kiran Graden, uttam Naga r</Address>
<ph
-
no> 9811836856 </Ph
-
no>
<Student Record>
<Name> Shweta Chopra </Name>
<PROGRAMME> MCA </PROGRAMME>
<E
-
NO> 063502656 </E
-
NO>
<ADDRE SS> A
-
17/F,u.n </ADDRESS>
<ph.no> 9958621533 </ph.no>
</student record>
</student records>
Issued.jsp
<% @ language=”java” import=”java.co.x” %>
<html.
<body>
<% string b1 = response.getParameter(“a”);
Class.for Name(“Com.mysql.jdbc.Driver”);
Connection con = drivermanager.getconnetion(“jdbc:mysql://localhost”institute”, “ro
ot”,
“1234”>
Statement st= con.createstatement();
Result rs= st.execute update (“update library set status=”issued” whereBook_title=””
%>
Search.jsp
<html>
<body>
<form action=”searchavailable” method=post”>
Enter Book name<input type=”text” name=”a”>
Se
arch For availability
<input type=”submit” value”search for
availability
”>
</form>
</body>
</html>
Searchavailable.jsp
<% @ language=”java” import=”java.io.x”, “java.sql.x”%>
<html>
<body>
<%
String = response.getParameter(“a”);
Class.forName(“com.mysql.
jdbs.Driver”);
Connection con=DriverManager.getConnection(“jdbc”.mysql://localhost/institute”, “root”,
“1234”);
Statement sr
-
con.createstatement ();
Resukt rs=st.executeQuery (“select status from Library where Book_title=”+a+”’”);
String out= rs.getString(
1);
Out.printer(n(“status=” +out+);
%>
</body>
</html>
PART
-
II: MCS
-
053 (Computer Graphics and Multimedia)
Q1: Write a program in C/C++ using OpenGL to draw a circle of red colour inside of a
triangle of blue colour on a background of yellow colour.
So
lution:
/*
* GL02Shape2D.cpp
* Drawing Simple 2D colored Shapes: quad, triangle, polygon.
*/
#include <gl/glut.h> // also included gl.h, glu.h
// Initialize OpenGL Graphics
void initGL() {
// Set clearing color to black (for filling the backgr
ound)
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
}
// Handler for window
-
paint event. Call back whenever window needs to be re
-
painted.
void display() {
glClear(GL_COLOR_BUFFER_BIT); // Clear the color buffer with current
clearing color
// De
fine shapes enclosed with a pair of glBegin and glEnd
glBegin(GL_QUADS); // Each set of 4 vertices form a quad
glColor3f(1.0f, 0.0f, 0.0f); // Red
glVertex2f(
-
0.8f, 0.1f); // Define vertices in counter
-
clockwise
glVert
ex2f(
-
0.2f, 0.1f);
glVertex2f(
-
0.2f, 0.7f);
glVertex2f(
-
0.8f, 0.7f);
glColor3f(0.0f, 0.0f, 1.0f); // Blue
glVertex2f(
-
0.7f,
-
0.6f);
glVertex2f(
-
0.1f,
-
0.6f);
glVertex2f(
-
0.1f, 0.0f);
glVertex2f(
-
0.7f, 0.0f);
glColor3f(1.0f, 1.0f, 1.0f); // White
glVertex2f(
-
0.9f,
-
0.7f);
glVertex2f(
-
0.5f,
-
0.7f);
glVertex2f(
-
0.5f,
-
0.3f);
glVertex2f(
-
0.9f,
-
0.3f);
glEnd();
glBegin(GL_TRIANGLES); // Each set of 3 vertices for
m a triangle
glColor3f(1.0f, 0.0f, 1.0f); // Magenta
glVertex2f(0.1f,
-
0.6f);
glVertex2f(0.7f,
-
0.6f);
glVertex2f(0.4f,
-
0.1f);
glColor3f(1.0f, 1.0f, 0.0f); // Yellow
glVertex2f(0.3f,
-
0.4f);
glVertex2f(0.9f,
-
0.4f);
glVertex2f(0.6f,
-
0.9f);
glEnd();
glBegin(GL_POLYGON); // The vertices form one closed polygon
glColor3f(0.0f, 1.0f, 1.0f); // Cyan
glVertex2f(0.4f, 0.2f);
glVertex2f(0.6f, 0.2f);
glVertex2f(0.7f, 0
.4f);
glVertex2f(0.6f, 0.6f);
glVertex2f(0.4f, 0.6f);
glVertex2f(0.3f, 0.4f);
glEnd();
glFlush(); // Render now
}
// Main function: GLUT runs as a Console Application
int main(int argc, char** argv) {
glutInit(&argc, arg
v); // Initialize GLUT
glutInitWindowSize(320, 320); // Set the initial Window's width and
height
glutInitWindowPosition(50, 50); // Position the initial Window's top
-
left
corner
glutCreateWindow("2D Shapes"); // Create window with the
given title
glutDisplayFunc(display); // Register callback handler for window
re
-
paint event
initGL(); // Our own OpenGL initialization
glutMainLoop(); // Enter infinitely event
-
processing loop
retur
n 0;
}
Q2: Write a program in C or C++ to Cohen
-
Sutherland line clipping algorithm
Solution:
*
-
Line clipping using cohen sutherland algo
-
*/
/*
------------------------------------------------------------
*/
#include<stdio.h>
#include<graphics.h>
#inclu
de<conio.h>
typedef unsigned int outcode;
enum { TOP=0x1, BOTTOM=0x2, RIGHT=0x4, LEFT=0x8 };
int calcode(float,float,float,float,float,float);
void lineclip(float x0,float y0,float x1,float y1,float xwmin,float ywmin,float xwmax,float
ywmax )
// float x0,y
0,x1,y1,xwmin,ywmin,xwmax,ywmax;
{
int gd,gm;
outcode code0,code1,codeout;
int accept = 0, done=0;
code0 = calcode(x0,y0,xwmin,ywmin,xwmax,ywmax);
code1 = calcode(x1,y1,xwmin,ywmin,xwmax,ywmax);
do{
if(!(code0 | code1))
{ accept =1 ; done =1; }
else
if(cod
e0 & code1) done = 1;
else
{
float x,y;
codeout = code0 ? code0 : code1;
if(codeout & TOP)
{
x = x0 + (x1
-
x0)*(ywmax
-
y0)/(y1
-
y0);
y = ywmax;
}
else
if( codeout & BOTTOM)
{
x = x0 + (x1
-
x0)*(ywmin
-
y0)/(y1
-
y0);
y = ywmin;
}
else
if ( codeout & RIGHT)
{
y = y
0+(y1
-
y0)*(xwmax
-
x0)/(x1
-
x0);
x = xwmax;
}
else
{
y = y0 + (y1
-
y0)*(xwmin
-
x0)/(x1
-
x0);
x = xwmin;
}
if( codeout == code0)
{
x0 = x; y0 = y;
code0=calcode(x0,y0,xwmin,ywmin,xwmax,ywmax);
}
else
{
x1 = x; y1 = y;
code1 = calcode(x1,y1,xwmin,ywmin,xwmax,ywmax
);
}
}
} while( done == 0);
if(accept) line(x0,y0,x1,y1);
rectangle(xwmin,ywmin,xwmax,ywmax);
getch();
}
/*
--------------------------------------------------------------------
*/
int calcode (float x,float y,float xwmin,float ywmin,float xwmax,float ywmax)
// float x,y,xwmin,ywmin,xwmax,ywmax;
{
int code =0;
if(y> ywmax)
code |=TOP;
else if( y<ywmin)
code |= BOTTOM;
else if(x > xwmax)
code |= RIGHT;
else if ( x< xwmin)
code |= LEFT;
return(code);
}
/*
-------------------------------------------------
*/
main()
{
float x2,y2,x1,y1,xwmin,ywmin,xwmax,ywmax;
int gd,gm;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"C:
\
\
TC
\
\
BGI");
printf("
\
n
\
n
\
tEnter the co
-
ordinates of Line :");
printf("
\
n
\
n
\
tX1 Y1 : ");
scanf("%f %f",&x1,&y1);
printf("
\
n
\
n
\
tX2 Y2 : ");
scanf("%f %f",&x2
,&y2);
printf("
\
n
\
tEnter the co_ordinates of window :
\
n ");
printf("
\
n
\
txwmin , ywmin : ");
scanf("%f %f",&xwmin,&ywmin);
printf("
\
n
\
txwmax , ywmax : ");
scanf("%f %f",&xwmax,&ywmax);
line(x1,y1,x2,y2);
rectangle(xwmin,ywmin,xwmax,ywmax);
getch();
cleardev
ice();
lineclip(x1,y1,x2,y2,xwmin,ywmin,xwmax,ywmax );
getch();
closegraph();
}
/***************** COHEN
-
SUTHERLAND LINE CLIPPING ***************/
Q3: Write a program in C/C++ using OpenGL to draw a hard wire diagram as shown in
figure given below. Us
e basic primitives of openGL.
100
40
40 100
Solution
Int main (int arg c , char ** arg v ) {
glvtInit ( & arg c, arg v);
glvInit Window Size ( 320, 320 );
glvInit Window Position ( 50, 50 );
glvInit Create Window ( “
2 D Shapes”);
glvInit Display Func ( display);
init GL();
glvertex 3f (
-
1. 0 f,
-
0.5 f,
-
4.0f);
glvertex 3f (1. 0 f
,
-
0.5 f,
-
4.0f);
glvertex 3f (0. 0 f
,
-
0.5 f,
-
4.0f);
glvertex 3f (0. 0 f
,
-
0.9 f,
-
4.0f);
glvertex 3f (1. 0 f
,
-
0.0f,
0.0f);
glvertex 2f (
-
1. 8 f
,
-
0.1f );
glvertex 2f (
-
1. 2 f
,
-
0.1f );
glvertex 2f (
-
1. 2 f
,
-
0.7f );
glvertex 2f (
-
1. 8 f
,
-
0.7f );
glvertex 2f (
-
3.0 f
,
s.of, 2.9f );
glEnd ( );
}
Q4: Write a program in C/C++ using OpenGL to
perform a 3
-
Dimensi
onal
transformation, such as translation ,rotation and reflection, on a given rectangle.
Solution:
#include <stdio.h>
#include <stdlib.h>
#include<graphics.h>
#include<conio.h>
void draw3d(int fs,int x[20],int y[20],int tx,int ty,int d);
void draw3d(i
nt fs,int x[20],int y[20],int tx,int ty,int d)
{
int i,j,k=0;
for(j=0;j<2;j++)
{
for(i=0;i<fs;i++)
{
if(i!=fs
-
1)
line(x[i]+tx+k,y[i]+ty
-
k,x[i+1]+tx+k,y[i+1]+ty
-
k);
else
line(x[i]+tx+k,y[i]+ty
-
k,x[0]+tx+k,y[0]+ty
-
k);
}
k=d;
}
for(i=0;i<fs;i++)
{
line(x[i]+t
x,y[i]+ty,x[i]+tx+d,y[i]+ty
-
d);
}
}
void main()
{
int gd=DETECT,gm;
int x[20],y[20],tx=0,ty=0,i,fs,d;
initgraph(&gd,&gm,"");
printf("no of sides (front view only) : ");
scanf("%d",&fs);
printf("co
-
ordinates : ");
for(i=0;i<fs;i++)
{
printf("(x%d,y%d)",i,i
);
scanf("%d%d",&x[i],&y[i]);
}
printf("Depth :");
scanf("%d",&d);
draw3d(fs,x,y,tx,ty,d);
printf("translation (x,y)");
scanf("%d%d",&tx,&ty);
draw3d(fs,x,y,tx,ty,d);
getch();
}
Enter the password to open this PDF file:
File name:
-
File size:
-
Title:
-
Author:
-
Subject:
-
Keywords:
-
Creation Date:
-
Modification Date:
-
Creator:
-
PDF Producer:
-
PDF Version:
-
Page Count:
-
Preparing document for printing…
0%
Comments 0
Log in to post a comment