0% found this document useful (0 votes)
591 views41 pages

PDF Generation with Servlet Example

The document contains instructions for various web technologies lab external programs. It includes code for creating HTML lists, tables, frames, and form validation using JavaScript. It also provides designs for pages required for an online bookstore website, including home, links, title, login, and registration pages.

Uploaded by

Vinod Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
591 views41 pages

PDF Generation with Servlet Example

The document contains instructions for various web technologies lab external programs. It includes code for creating HTML lists, tables, frames, and form validation using JavaScript. It also provides designs for pages required for an online bookstore website, including home, links, title, login, and registration pages.

Uploaded by

Vinod Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

1.a) Create a simple HTML page which demonstrates the use of the various types of lists <html> <head> <title>HTML Lists</title> </head> <body> <h2>Unordered Lists</h2> <ul> <li>Apple</li> <li>Banana</li> <li>Grapes</li> <li>Mango</li> </ul> <h2>Ordered Lists</h2> <ol> <li>New Delhi</li> <li>Hyderabad</li> <li>Mumbai</li> <li>Chennai</li> </ol> <h2>Definition Lists</h2> <dl> <dt>J2SE</dt> <dd>Java 2 Standard Edition is for Stand-alone applications</dd> <dt>J2EE</dt> <dd>Java 2 Enterprise Edition is for Web-based applications</dd> <dt>J2ME</dt> <dd>Java 2 Mobile Edition is for developing Mobile applications</dd> </dl> </body> </html> Output:

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

1.b) Create a HTML table for Time Table

<html> <head> <title>Time Table Of CSE Branch</title></head> <body bgcolor="pink"> <center> <table border="1"align="center" bgcolor="red"> <tr align="center"><th rowspan=2>Day<th colspan=7>Lecture timings</tr> <tr> <th>9-00 to 9-50<th>9-50 to 10-40<th>10-40 to 11-30<th>11-30 to 12-20<th>12-50 to 140<th>1-40 to 2.30<th>2-30 to 3.20 </tr> <tr align=center> <td>Monday <td colspan=3>Wt <td>Aca <td>DwDm <td>Mc <td>Np </tr> <tr align=center> <td>Tuesday <td>Wt <td>Mc <td>Spm <td>DwDm 2

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

<td>Aca <td>Np <td>Aca </tr> <tr align=center> <td>Wednesday <td>Np <td>Aca <td>Mc <td>Wt <td>DwDm <td>Spm <td>DmDw </tr> <tr align=center> <td>Thursday <td>Wt <td>Np <td>Spm <td>Aca <td>Np <td>DwDm <td>Mc </tr> <tr align=center> <td>Friday 3

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

<td>Wt <td>Mc <td>Spm <td>Aca <td colspan=3>Np </tr> <tr align=center> <td>Saturday <td>Aca <td>Mc <td>Spm <td>Wt <td>Np <td>DwDm <td>MC </tr> <caption align="bottom"><b><br>Time Table</b></caption> </table> </center> </body> </html> Output:

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

2. a)Write HTML code to create a frameset with two vertical frames :the first frame is 250 pixels wide. Fill the first frame(left _vertical) with links.html. Second frame further divided into two horizontal frames(400px,350px).Fill the Top frame (right_top)with cse.html and Bottom(right_bottom) with it.html home.html <html> <head> <title>Welcome File</title> </head> <frameset cols="250,*" border=1> <frame src="title.html" scrolling= noresize> <frameset rows="400,*"> <frame src="cse.html" scrolling=no noresize> <frame src="it.html" scrolling= noresize> </frameset> </html> title.html <body bgcolor="dddcff"> <br><br><br><br><CENTER><h1>Welcome To VitsSet<br><br><br><br>Karimnagar</center></h1></body> cse.html <html> <head> <title>Computer Science and Engineering</title> </head> <body bgcolor="dddcff"> <CENTER><h1>Welcome To CSE</center></h1></body></html> it.html <html> <head> <title>Information Technology</title> </head> <body bgcolor="dddcff"> <CENTER><h1>Welcome To IT</center></h1></body></html> Output: 5

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

2.b) Write a Java script that reads an integer and determines and displays whether it is an odd or even number

<html> <head> <title>Even-Odd JavaScript</title> <script language="JavaScript"> function check() { var x=parseInt(f1.t1.value); if(x%2==0) window.alert("Even Number !"); else window.alert("Odd Number !"); } </script> </head> <body> <form name="f1" method="post" > 6

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

Enter a Number:<input type="text" name="t1"> <br> <input type="RESET"> <input type="button" value="CHECK" onClick="check()"> </form> </body> </html> Output:

3.a) Program for onload event <html> <head> <title>Body onload example</title> </head> <body onload="alert('This page has finished loading!')"> <div align=top ><b><h1><font color="red">Welcome to my page</font></h1></b></div> <alt><img src="C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Sunset.jpg" height=200 width=200> </body> </html> output: 7

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

3.b)Program for onsubmit event <HTML> <HEAD><TITLE> onSubmit Event Handler </TITLE></HEAD> <BODY> <H3>Example of onSubmit Event Handler </H3> Type your name and press the button<BR> <FORM NAME="myform" onSubmit="alert('Thank you ' + myform.data.value +'!')"> <INPUT TYPE="text" NAME="data"> <INPUT TYPE="submit" VALUE="Submit this form"> </FORM> </BODY> <HTML> output:

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

3.c)program for onclick event <HTML> <HEAD> <TITLE>Example of onClick Event Handler</TITLE> <SCRIPT> function valid(form) { var input = form.data.value; alert("Hello " + input + " ! Welcome..."); } </SCRIPT> </HEAD> <BODY> <H3> Example of onClick Event Handler </H3> Click on the button after inputting your name into the text box:<BR> <FORM> <INPUT TYPE="text" NAME="data"> <INPUT TYPE="button" VALUE="Click Here" onClick="valid(this.form)"> </FORM> </BODY> </HTML> output:

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

4) Design the following static web pages required for an online book store web site 1) home page 2)links page 3)title page 4) login page 5)registration page 6) message page 1) Home.html <html> <head> <title>ONLINE BOOK STORAGE</title> </head> <frameset rows="15%,85%" border=1> <frame src="title.html" scrolling= noresize> <frameset cols="20%,65%" border=1> <frame src="links.html" scrolling=no noresize> <frame src="msg.html" scrolling=no noresize> </frameset> </html> output:

2) Links.html 10

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

<body bgcolor=#dddcff> <br><br><br><br><table> <ul> <tr><td><a href="home.html" target=_parent><li>HOME</li></a></td></li></tr> <tr><td><a href="login.html" target="_parent"><li>LOGIN</li></a></td></tr> <tr><td><a href="reg.html" target="_parent"><li>REGISTRATION</li></a></td></tr></ul></table></body> output:

3) Title.html <body bgcolor=dddcff> <h1 align=center> <img src= C:\Documents and Settings\MAHESH\Desktop\vitslogo.jpgheight=200 width=100> <font color="black">ONLINE BOOK STORAGE</font></h1></body> output:

4.a) Login.html <br><br><br><center><font color=black><h1>Login Form</h1></font></center> 11

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

<body bgcolor=#dddcff> <form name=login method=post action="logmsg.html"> <br><br><br> <table align=center> <tr><td>UserName</td><td><input type=text name="uid"></td></tr> <tr><td>Password</td><td><input type=password name=pwd></td></tr> <tr><td><input type=submit value=Login></td><td><input type=reset value=clear></td></tr> </table></form></body> output:

4.b) Logmsg.html <body bgcolor="dddcff"> <CENTER><h1>U are Logged In Successfully</center></h1></body> output:

5.a) Reg.html <head><title> Registration Form</title></head> <h1><center><font color=#dddcff>Registration Form</font></center></h1> 12

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

<body bgcolor=dddcff> <form name=reg method=post action="regmsg.html"> <center><h4>**No Field Should Be Left Blank**</h4></center> <table align=center> <tr><td>User Name</td><td><input type=text name=uid></td></tr> <tr><td>Password</td><td><input type=password name=pwd></td></tr> <tr><td>Confirm Password</td><td><input type=password name=tpwd></td></tr> <tr><td>Name</td><td><input type=text name=tname></td></tr> <tr><td>Date of Birth</td> <td><select name=date> <option value=0>dd</option> <option value=1>1</option> <option value=2>2</option> <option value=3>3</option> <option value=4>4</option> <option value=5>5</option> <option value=6>6</option> <option value=7>7</option> <option value=8>8</option> <option value=9>9</option> <option value=10>10</option> <option value=11>11</option> <option value=12>12</option> <option value=13>13</option> <option value=14>14</option> <option value=15>15</option> <option value=16>16</option> <option value=17>17</option> <option value=18>18</option> <option value=19>19</option> <option value=20>20</option> <option value=21>21</option> <option value=22>22</option> <option value=23>23</option> <option value=24>24</option> <option value=25>25</option> <option value=26>26</option> <option value=27>27</option> <option value=28>28</option> <option value=29>29</option> <option value=30>30</option> <option value=31>31</option></select> <select name=month> <option value=0>mm</option> <option value=1>Jan</option> <option value=2>feb</option> <option value=3>mar</option> <option value=4>apr</option> <option value=5>may</option> <option value=6>june</option> <option value=7>july</option> 13

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

<option value=8>aug</option> <option value=9>sep</option> <option value=10>oct</option> <option value=11>nov</option> <option value=12>dec</option></select> <select name=year> <option value=0>yy</option> <option value=1>1975</option> <option value=2>1976</option> <option value=3>1977</option> <option value=4>1978</option> <option value=5>1979</option> <option value=6>1980</option> <option value=7>1981</option> <option value=8>1982</option> <option value=9>1983</option> <option value=10>1984</option> <option value=11>1985</option> <option value=12>1986</option> <option value=13>1987</option> <option value=14>1988</option> <option value=15>1989</option> <option value=16>1990</option></select></td></tr> <tr><td>Country</td><td><select name=country> <option value=0>sel</option> <option value=1>Australia</option> <option value=2>Austria</option> <option value=3>Bangladesh</option> <option value=4>Barbados</option> <option value=5>Bermuda</option> <option value=6>China</option> <option value=7>Cuba</option> <option value=8>Denmark</option> <option value=9>Europe</option> <option value=10>India</option> <option value=11>Pakistan</option> <option value=12>USA</option></select></td> <tr><td>Gender</td><td>Male<input type=radio name=gender checked>Female<input type=radio name=gender></td></tr> <tr><td>Email Id</td><td><input type=text name=eid></td></tr> <tr><td>Address</td><td><textarea name=addr></textarea></td></tr> <tr><td>Security Question1</td> <td><select name=ques> <option value=0>select a Question</option> <option value=1>What is your first school's name?</option> <option value=2>What is your pet name?</option> <option value=3>What is your husband's name?</option> <option value=4>When did u first met your partner? </option></td></tr> <tr><td>Answer</td><td><input type=text name=ans></td></tr> <tr><td>Security Question2</td> <td><select name=ques2> 14

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

<option value=0>select a Question</option> <option value=1>When did u first saw ur gf?</option> <option value=2>What is ur favourite dish?</option> <option value=3>When did u first saw ur bf?</option> <option value=4>What is ur pet's name? </option></td></tr> <tr><td>Answer</td><td><input type=text name=ans2></td></tr> <tr><td><input type=submit value=submit></td><td><input type=reset value=clear></td></tr> </table></form></body> output:

5.b)Regmsg.html <body bgcolor=dddcff> <center><h1>U are Registered Successfully </h1></center></body> output:

6) Msg.html <body bgcolor="#dddcff"> <br><br><br><br><br><br> <center><font size="5">Welcome to Online book storage.<br><br>Press login if you are having id, otherwise press registration.</font></center></body> output: 15

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

5) Design the following static web pages required for an online book store web site 1) home page 2)links page 3)title page 4)message page 5)book catalogue page 1) Home.html <html> <head> <title>ONLINE BOOK STORAGE</title> </head> <frameset rows="15%,85%" border=1> <frame src="title.html" scrolling= noresize> <frameset cols="20%,65%" border=1> <frame src="links.html" scrolling=no noresize> <frame src="msg.html" scrolling=no noresize> </frameset> </html> output:

16

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

2) Links.html <body bgcolor=#dddcff> <br><br><br><br> <table> <ul> <tr><td><a href="home.html" target=_parent><li>HOME</li></a></td></li></tr> <tr><td><a href="login.html" target="_parent"><li>LOGIN</li></a></td></tr> <tr><td><a href="reg.html" target="_parent"><li>REGISTRATION</li></a></td></tr> output:

3) Title.html <body bgcolor=dddcff> 17

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

<h1 align=center> <img src= C:\Documents and Settings\MAHESH\Desktop\vitslogo.jpgheight=200 width=100> <font color="black">ONLINE BOOK STORAGE</font></h1></body> output:

4) Msg.html <body bgcolor="#dddcff"> <br><br><br><br><br><br> <center><font size="5">Welcome to Online book storage.<br><br>Press login if you are having id, otherwise press registration.</font></center></body> output:

5.a) Bokcat.html <body bgcolor="dddcff"> <form name="book" action="next.html" method=post> 18

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

<table align=center> <br><br><br><br><br> <tr><td>Book Title:&nbsp;</td><td><input type="text" name=btitle></td></tr> <tr><td><input type=submit value="ok"></td><td><input type="reset" value=clear></td></tr> </table></body> output:

5.b)Next.html <body bgcolor=dddcff> <form name=bk method=post action="next2.html"> <br><br><br><br><br> <table align=center> <tr><td>Title:&nbsp;</td><td><input type="text" name=title></td></tr> <tr><td>Author:&nbsp;</td><td><input type=text name=auth></td></tr> <tr><td><input type=submit value="ok"></td><td><input type=reset value =clear></td></tr> </table></body> output:

19

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

5.c)Next2.html <body bgcolor=dddcff> <form name=bok method=post action="next3.html"> <br><br><br><br><br> <table align=center> <tr><td>Login ID</td><td><input type="text" name=lid></td></tr> <tr><td>Title</td><td><input type="text" name=title></td></tr> <tr><td>No of Books</td><td><input type="text" name=nob></td></tr> <tr><td>Cost</td><td><input type="text" name=cost></td></tr> <tr><td>Date</td><td><input type="text" name=date></td> <td>[dd/mm/yyyy]</td></tr> <tr><td><input type="submit" value=ok></td><td><input type="reset" value=clear></td></tr> </table></body> output:

5.d) Next3.html 20

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

<body bgcolor=dddcff> <form name=bk method=post> <br><br><br><br><br> <table align=center> <tr><td>Login ID</td><td><input type="text" name="lid"></td></tr> <tr><td>Password</td><td><input type="password" name="pwd"></td></tr> <tr><td>Amount</td><td><input type="text" name="amt"></td></tr> <tr><td>Credit Card No</td><td><input type="text" name="cc"></td></tr> <tr><td><input type="submit" value=ok></td><td><input type="reset" value=clear></td></tr> </table></body> output:

6)Write JavaScript to validate the following fields of the above registration page. 1. Name (Name should contains alphabets and the length should not be less than 6 characters). 2. Password (Password should not be less than 6 characters length). 3. E-mail id (should not contain any invalid and must follow the standard pattern [email protected]) 4. Phone number (Phone number should contain 10 digits only). Login.html <head><center><font color=black><h1>Login Form</h1></font></center></head> <script language="javascript"> function validate() { var uname=login.uid.value; var paswd=login.pwd.value; if(uname.length==0) { alert("Enter User Name"); 21

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

login.uid.focus(); return false; } if(uname.length<3) { alert("Enter Valid User Name"); login.uid.focus(); return false; } if(paswd.length==0) { alert("Enter password"); login.pwd.focus(); return false; } if(paswd.length<6 || paswd.length>15) { alert("Enter Valid Password"); login.pwd.focus(); return false; }} </script> <body bgcolor=dddcff> <form name=login method=post onSubmit="return validate()" action="logmsg.html"> <br><br><br> <table align=center> <tr><td>UserName</td><td><input type=text name="uid"></td></tr> <tr><td>Password</td><td><input type=password name=pwd></td></tr> <tr><td><input type=submit value=Login></td><td><input type=reset value=clear></td></tr> </table> </form> </body> output:

Reg1.html <body bgcolor="dddcff"> <Head><h1><center><font color=blue>Registration Form</font></center></h1> 22

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

<title> Registration Form</title></head> <center><h4>**No Field Should Be Left Blank**</h4></center> <script language="javascript"> function validate() { var uname=reg.uid.value; var paswd=reg.pwd.value; var tnam=reg.tname.value; var tpd=reg.tpwd.value; var tans=reg.ans.value; var t2ans=reg.ans2.value; var taddr=reg.addr.value; var teid=reg.eid.value; var date=reg.date.value; var month=reg.month.value; var year=reg.year.value; if(uname.length==0) { alert("Enter User Name"); reg.uid.focus(); return false; } if(uname.length<3) { alert("UserName Should not be less than 3 Characters"); reg.uid.focus(); return false; } if(paswd.length==0) { alert("Enter password"); reg.pwd.focus(); return false; } if(paswd.length<6 || paswd.length>15) { alert("Password must be in the range of 6-15 characters"); reg.pwd.focus(); return false; } if(tpd.length==0) { alert("Enter Confirm password"); reg.tpwd.focus(); return false; } if(paswd!=tpd) { alert("Password and Confirmation Password are Mismatched...!"); reg.pwd.focus(); return false; 23

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

} if(tnam.length==0) { alert("Enter Name"); reg.tname.focus(); return false; } if(date=="0") { alert("choose a date for date of birth"); reg.date.focus(); return false; } if(month=="0") { alert("choose a Month for date of birth"); reg.month.focus(); return false; } if(year=="0") { alert("choose an Year for date of birth"); reg.year.focus(); return false; } if(!(year=="2" || year=="6" || year=="10" || year=="14") && month=="2" && date=="29") { alert("Invalid Date"); reg.date.focus(); return false; } if(month=="2" && date>29) { alert("Invalid Date"); reg.date.focus(); return false; } if((month=="4" || month=="6" || month=="9" || month=="11") && date>30) { alert("Invalid Date"); reg.date.focus(); return false; } if(reg.country.value==0) { alert("Select Country"); reg.country.focus(); return false; } if(teid.length==0) { 24

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

alert("Enter Email Id"); reg.eid.focus(); return false; } if(teid.lastIndexOf('@')==-1 || teid.lastIndexOf('.')==-1) { alert("Email should contain '@' and '.'"); reg.eid.focus(); return false; } if(teid.charAt(0)=="." || teid.charAt(0)=="@" || teid.charAt(1)=="." || teid.charAt(1)=="@" || teid.lastIndexOf('@')>teid.lastIndexOf('.')) { alert("Invalid Email Format"); reg.eid.focus(); return false; } if(taddr.length==0) { alert("Enter Address"); reg.addr.focus(); return false; } if(reg.ques.value==0) { alert("Select a Question"); reg.ques.focus(); return false; } if(tans.length==0) { alert("Enter Answer 1"); reg.ans.focus(); return false; } if(reg.ques2.value==0) { alert("Select Question 2"); reg.ques2.focus(); return false; } if(t2ans.length==0) { alert("Enter Answer 2"); reg.ans2.focus(); return false; }} </script> <form name=reg method=post onSubmit="return validate()" action="regmsg.html"> <table align=center> <tr><td>User Name</td><td><input type=text name=uid></td></tr> 25

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

<tr><td>Password</td><td><input type=password name=pwd></td></tr> <tr><td>Confirm Password</td><td><input type=password name=tpwd></td></tr> <tr><td>Name</td><td><input type=text name=tname></td></tr> <tr><td>Date of Birth</td></tr> <td><select name=date> <option value=0>dd</option> <option value=1>1</option> <option value=2>2</option> <option value=3>3</option> <option value=4>4</option> <option value=5>5</option> <option value=6>6</option> <option value=7>7</option> <option value=8>8</option> <option value=9>9</option> <option value=10>10</option> <option value=11>11</option> <option value=12>12</option> <option value=13>13</option> <option value=14>14</option> <option value=15>15</option> <option value=16>16</option> <option value=17>17</option> <option value=18>18</option> <option value=19>19</option> <option value=20>20</option> <option value=21>21</option> <option value=22>22</option> <option value=23>23</option> <option value=24>24</option> <option value=25>25</option> <option value=26>26</option> <option value=27>27</option> <option value=28>28</option> <option value=29>29</option> <option value=30>30</option> <option value=31>31</option></select> <select name=month> <option value=0>mm</option> <option value=1>Jan</option> <option value=2>feb</option> <option value=3>mar</option> <option value=4>apr</option> <option value=5>may</option> <option value=6>june</option> <option value=7>july</option> <option value=8>aug</option> <option value=9>sep</option> <option value=10>oct</option> <option value=11>nov</option> <option value=12>dec</option></select> 26

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

<select name=year> <option value=0>yy</option> <option value=1>1975</option> <option value=2>1976</option> <option value=3>1977</option> <option value=4>1978</option> <option value=5>1979</option> <option value=6>1980</option> <option value=7>1981</option> <option value=8>1982</option> <option value=9>1983</option> <option value=10>1984</option> <option value=11>1985</option> <option value=12>1986</option> <option value=13>1987</option> <option value=14>1988</option> <option value=15>1989</option> <option value=16>1990</option></select></td></tr> <tr><td>Country</td><td><select name=country> <option value=0>sel</option> <option value=1>Australia</option> <option value=2>Austria</option> <option value=3>Bangladesh</option> <option value=4>Barbados</option> <option value=5>Bermuda</option> <option value=6>China</option> <option value=7>Cuba</option> <option value=8>Denmark</option> <option value=9>Europe</option> <option value=10>India</option> <option value=11>Pakistan</option> <option value=12>USA</option></select></td> <tr><td>Gender</td><td>Male<input type=radio name=gender checked>Female<input type=radio name=gender></td></tr> <tr><td>Email Id</td><td><input type=text name=eid></td></tr> <tr><td>Address</td><td><textarea name=addr></textarea></td></tr> <tr><td>Security Question1</td> <td><select name=ques> <option value=0>select a Question</option> <option value=1>What is your first school's name?</option> <option value=2>What is your pet name?</option> <option value=3>What is your husband's name?</option> <option value=4>When did u first met your partner? </option></td></tr> <tr><td>Answer</td><td><input type=text name=ans></td></tr> <tr><td>Security Question2</td> <td><select name=ques2> <option value=0>select a Question</option> <option value=1>When did u first saw ur gf?</option> <option value=2>What is ur favourite dish?</option> <option value=3>When did u first saw ur bf?</option> <option value=4>What is ur pet's name? </option></td></tr> 27

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

<tr><td>Answer</td><td><input type=text name=ans2></td></tr> <tr><td><input type=submit value=submit></td><td><input type=reset value=clear></td></tr> </table> </form> </body> output:

7) Design a web page using CSS (Cascading Style Sheets) which includes the following: 1) Use different font, styles: In the style definition you define how each selector should work .Then, in the body of your pages, you refer to these selectors to activate the styles. 2) Set a background image for both the page and single elements on the page. 3)Control the repetition of the image with the background-repeat property Cas.css a:link{color:black;} a:visited{color:pink;} a:active{color:red;} a:hover{color:green;} .right { text-align:center; text-decoration:underline; font-weight:bold; color:blue; font-family:comic sans ms; font-size:30; } 28

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

.image { text-align:left; font-family:"monotype corsiva"; font-weight:10; } .image1 { background-image:url("C:\Documents and Settings\All Users\My Documents\My Pictures\krishna.jpg"); background-attachment:fixed; background-repeat:no-repeat; width:150; height:150; } table { align:center;border:10; border-style:ridge; border-color:yellow;} htm.html: <html> <head> <link rel="stylesheet" href="cas.css" type="text/css"> <style> .xlink{ text-decoration:none;font-weight:bold;cursor:crosshair;} .ylink{text-decoration:underline;font-weight:bold;cursor:help;} </style> </head> <body class="image"> <p style="text-align:right;"> <a href="registration.html" class="xlink"> Reg Link</a>&nbsp;&nbsp; <a href="topframe.html" class="ylink"> Help Link</a> </p> <p class="right">PVPSIT</p> <div style="position:relative;font-size:90px;z-index:5;color:purple;">PVPSIT</div> <div style="position:relative;font-size:50px;z-index:1;top:-70; left:5;color:blue;">CSE</div> <div style="position:relative;font-size:90px;z-index:1;color:purple;">PVPSIT</div> <div style="position:relative;font-size:50px;z-index:5;top:-70; left:5;color:blue;">CSE</div> <table align="center" class="image1"> <tr> <td> Fruits</td> <td> Mango</td> </tr> </table> </body> </html> output:

29

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

8)Write an XML file which will display the Book information which includes the following: 1) Title of the book 2) Author Name 3) ISBN number 4) Publisher name 5) Edition 6) Price Write a Document Type Definition (DTD) to validate the above XML file. Display the XML file as follows. The contents should be displayed in a table. The header of the table should be in color GREY. And the Author names column should be displayed in one color and should be capitalized and in bold. Use your own colors for remaining columns. Use XML schemas XSL and CSS for the above purpose. XML document (bookstore.xml) <bookstore> <book> <title>web programming</title> <author>chrisbates</author> <ISBN>123-456-789</ISBN> <publisher>wiley</publisher> <edition>3</edition> <price>350</price> </book> <book> <title>internet worldwideweb</title> 30

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

<author>ditel&amp;ditel</author> <ISBN>123-456-781</ISBN> <publisher>person</publisher> <edition>3</edition> <price>450</price> </book> </bookstore> XML document Validation using DTD DTD document (bookstore.dtd) <?xml version="1.0" encoding="UTF-8"?> <!ELEMENT bookstore (book+)> <!ELEMENT book (title,author,ISBN,publisher,edition,price)> <!ELEMENT title (#PCDATA)> <!ELEMENT author (#PCDATA)> <!ELEMENT ISBN (#PCDATA)> <!ELEMENT publisher (#PCDATA)> <!ELEMENT edition (#PCDATA)> <!ELEMENT price (#PCDATA)> XML document Validation using DTD XML Schema (bookstore.xsd) <?xml version="1.0" encoding="UTF-8"?> <xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="bookstore"> <xs:complexType> <xs:sequence> <xs:element name="book" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string"></xs:element> <xs:element name="author" type="xs:string"></xs:element> <xs:element name="ISBN" type="xs:string"></xs:element> <xs:element name="publisher" type="xs:string"></xs:element> <xs:element name="edition" type="xs:int"></xs:element> <xs:element name="price" type="xs:decimal"></xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> Display the XML file as follows. PROGRAM: display.xml: <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="bookstore.xsl"?> <bookstore> 31

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

<book> <title>Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book> <title>Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> <book> <title>Learning XML</title> <author>Erik T. Ray</author> <year>2003</year> <price>39.95</price> </book> </bookstore> bookstore.xsl: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html><body> <h2> My Books collection</h2> <table border="1"> <tr bgcolor="red"> <th align="left">title</th> <th align="left">author</th> </tr> <xsl:for-each select="bookstore/book"> <tr> <td><xsl:value-of select="title"/></td> <xsl:choose> <xsl:when test="price &gt; 30"> <td bgcolor="yellow"><xsl:value-of select="author"/></td> </xsl:when> <xsl:when test="price &gt; 10"> <td bgcolor="magneta"><xsl:value-of select="author"/></td> </xsl:when> <xsl:otherwise> <td><xsl:value-of select="author"/></td> </xsl:otherwise> </xsl:choose> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> output: 32

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

9) a.Write a servlet program for addition of the two numbers b.Write a servlet program for subtraction of the two numbers a)Add.java import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class Add extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); int x=Integer.parseInt(request.getParameter("a")); int y=Integer.parseInt(request.getParameter("b")); int sum=x+y; out.println("<h2>Addition="+sum); out.close(); } } ad.html <html> <body> <form action="/AddSubDemo/AdditionSubtraction" method="get"> Enter a:<input type="text" name="a"><br> Enter b:<input type="text" name="b"><br> 33

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

<input type="submit" value="Calculate"> </form> </body> </html> Web.xml <web-app> <servlet> <servlet-name>Hello</servlet-name> <servlet-class>Add</servlet-class> </servlet> <servlet-mapping> <servlet-name>Hello</servlet-name> <url-pattern>/AdditionSubtraction</url-pattern> </servlet-mapping> </web-app> b)Sub.java import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class Sub extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); int x=Integer.parseInt(request.getParameter("a")); int y=Integer.parseInt(request.getParameter("b")); int sub=x-y; out.println("<h2>Subtraction="+sub); out.close(); } } sb.html <html> <body> <form action="/AddSubDemo/AdditionSubtraction" method="get"> Enter a:<input type="text" name="a"><br> Enter b:<input type="text" name="b"><br> <input type="submit" value="Calculate"> </form> </body> </html> Web.xml 34

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

<web-app> <servlet> <servlet-name>Hello</servlet-name> <servlet-class>Sub</servlet-class> </servlet> <servlet-mapping> <servlet-name>Hello</servlet-name> <url-pattern>/AdditionSubtraction</url-pattern> </servlet-mapping> </web-app> Note: Write separate outputs for addition and subtraction output:

35

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

10) a. Write a JSP application to print 1 to 10 numbers b. Write a JSP program that displays current date and time a) numprint.jsp <html> <head> <title>JSP Prints 1 to 10</title> </head> <body> <h3>Printing 1 to 10 <br> <%for(int i=1;i<=10;i++){out.println(i);%> <br> <%}%> </body> </html> Web.xml: <web-app> </web-app> output: 36

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

b) date.jsp <html> <head> <title>Date & Time JSP</title> <meta http-equiv="refresh" content="1"> </head> <body> <h2> <%=new java.util.Date()%> </h2> </body> </html> Web.xml: <web-app> </web-app> output:

37

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

11).Create a HTML form with two input fields user name and age. pass these values to a servlet. In the servlet, determines whether user is eligible to vote or not and display the result back to client. Vote.java import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class Vote extends HttpServlet { public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String name=request.getParameter("uname"); int age=Integer.parseInt(request.getParameter("uage")); if(age<18) out.println("<h2><font color='red'>"+name+" is not eligible to Vote"); else out.println("<h2><font color='green'>"+name+" is eligible to Vote"); out.close(); } } 38

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

vote.html: <html> <body> <form action="/VT/Voting" method="post"> Enter Name:<input type="text" name="uname"><br> Enter Age:<input type="text" name="uage"><br> <input type="submit" value="VOTE"> </form> </body> </html> Web.xml: <web-app> <servlet> <servlet-name>Voters</servlet-name> <servlet-class>Vote</servlet-class> </servlet> <servlet-mapping> <servlet-name>Voters</servlet-name> <url-pattern>/Voting</url-pattern> </servlet-mapping> </web-app> output:

39

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

12.Write a servlet program that displays current date and time DateServlet.java import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class DateServlet extends HttpServlet{ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ PrintWriter pw = response.getWriter(); Date today = new Date(); pw.println("<html><body bgcolor='magneta'>"); pw.println("<b>"+ today+"</b></body></html>"); } } web.xml <web-app> <display-name>Display current date with help of Servlet</display-name> <servlet> <servlet-name>DateSr</servlet-name> <servlet-class>DateServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>DateSr</servlet-name> 40

WEB TECHNOLOGIES LAB EXTERNAL PROGRAMS

[email protected]

<url-pattern>/DateDisplay</url-pattern> </servlet-mapping> </web-app> output:

41

You might also like