Академический Документы
Профессиональный Документы
Культура Документы
OUTPUT
</ul>
Syntax:
<ol [ type=1 | a| A| i|I] start=n] [compact]>
List of items enclosed by <li> </li> tag.
Attribute table
Value for
type
attribute
1
A
a
I
i
</ol>
Description
Example
Arabic numerals(the
default)
Capital letters
Small letters
Large roman letters
Small Roman letters
1,2,3..
A,B,C,D
a,b,c,d
I,II,III,IV
i,ii,iii,iv
6.Write a HTML program to print the INDEX of Project by using ordered list
<!2.Write a HTML program to print the Index of project by using ordered list>
<html>
<head>
<title> Malla Reddy Engineering College
</title>
8
7.Write a HTML program to print the courses of MREC by using Definition list
<!3.Write a HTML program to print the COURSES of MREC by using Definition list>
<html>
<head>
<title> Malla Reddy Engineering College
</title>
</head>
9
10
12
-----------16 Write a HTML program to desing Time table of III B.Tech CSE-A using tables
15
18
2. BUTTONS: buttons are most commonly used to submit a form, and some time used to clear or
reset a form and event to triggerclient side scripts.
creating buttons using the <input> element.
<input> element is used to create a button the type attribute following values
(i) submit : which creates a button that submit a form
(ii) reset: reset the form control with intial values.
(iii) button: which creates a button that is used to trigger
client side script when user clicks button.
syntax:
<input type="submit" name="btnName" value="btnValue"/>
<input type="reset" value="Clear form"/>
<input type="button" value="calculate" onclick="calculate()"/>
type: specifies the type of button (submit, reset or button)
name: Provides the name of the button
value: Enable to specify what text button should read.
size: Width of the button in pixels
onclick: Used to trigger a script when user clicks button.
using image for buttons:You can use image rather than using standard button. To create an image
button type attribute value is image.
syntax:
23
24
4.Radio Buttons:
Similar to check box either they can be on or off.Group of items will share the same name.You
should not use radio button as single form control.Provide the number of options but user can select
only one option.
Syntax:
<form>
<input type="radio" name=" radName" value="radValue"/>
NAME
</form>
21. Desing a HTML web page print Gender (male and female)
using Radio buttons.
<! Write HTML program to GenderMale, Female using
Radio button. -->
<html>
<head>
<title> MALLA REDDY ENGINEERING COLLEGE </title>
</head>
<body>
<h2> Gender</h2>
<form action="URL" method="get" name="fromName">
<input type="radio" name="chkGender" value="male"/>
26
5.SELECT BOX(DROP DOWN MENU or LIST BOX):Drop down select box allows users to select
one item from drop
down menu.It provides text input select box several options only one option will be selected.Drop
down menu uses <select> tag with <option> element.
syntax;
<select name="nameSelect" >
< option selected="selected" value=""> select Value </option>
<option value="value> Name</option>
.........
</select>
22..Write a HTML program select one color value among three colors(Red,Blue and Green) using
<select> tag.
! Write HTML program to select color red,blue,green usingselect tag. -->
<html>
<head>
<title> MALLA REDDY ENGINEERING COLLEGE </title>
</head>
<body>
<h2> Gender</h2>
<form action="URL" method="get" name="fromName">
<select name="setColor" >
< option selected="selected" value=""> select color </option>
<option value="red"> Red</option>
27
7.HIDDEN CONTROLS:
You want to pass information between pages without the user seeing it. You can use hidden form
controls.
Hidden controls should not be used for any sensitive information. Hidden control using <input>
element type attribute value is hidden.
Syntax: <form action="URL" method="get" name="formName">
<input type="hidden" name="hiddenName" value="homepage">
<input type="submit" value="clickFavourate page from site">
</form>
29.Desing a HTML web page hidden control
<! Desing a HTML web page hidden control -->
<html>
<head>
<title> MALLA REDDY ENGINEERING COLLEGE </title>
</head>
<body>
<p> The Contens Hidden from user View and choose the
following option to view the source page </p>
<form action="URL" method="get" name="formName">
<input type="hidden" name="hiddenName" value="homepage">
<input type="submit" value="clickFavourate page from site">
</form>
</body>
</html>
OUTPUT:
29
30
32
33
34
35
36
39
of
two numbers</title>
<script language = "javascript">
<!-function add() {
var x,y,sum;
x = window.prompt("Enter First Number"," ");
y = window.prompt("Enter Second Number"," ");
sum = parseInt(x) + parseInt(y);
document.writeln("<h1> THE SUM OF TWO NUMBERS
</h1>");
document.writeln("<h2> " + sum + "</h2>");
document.close();
}
//-->
</script>
</head>
<body onLoad="add()">
</body>
</html>
OUTPUT:
41
2) String manipulations:
Java script uses text strings
Most useful text manipulation involves regular
expressions
string manipulation involvs
joining strings
42
UT
49
<html>
<head> <title> CASE statement to print DAYS
</title>
<script language = "javascript">
<!-function day()
{
var n;
n = window.prompt("Enter 1 to 7 "," ");
n= parseInt(n);
switch(n)
{
case 1:
50
51
52
Registration
CSE
ECE
EEE
CIVIL
Catalogue
Cart
Homepagemain.html
<?XML version="1.0" encoding="iso-8859-1"?>
<html>
<head>
<title> Online Book store Web site </title>
</head>
<frameset rows="90,90,*">
<frame src="logo.html"/>
<frame src="menu.html"/>
<frameset cols="100,*">
<frame src="C:\Users\das\Desktop\wt lab\21_1_14_CSE_A_EXP1\left.html" />
<frame src="C:\Users\das\Desktop\wt lab\21_1_14_CSE_A_EXP1\main.html"
name="main_page"/>
</frameset>
53
56
Loginpage
60
61
3: VALIDATION: 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
name@domain.com)
4. Phone number (Phone number should contain 10 digits only).
Note : You can also validate the login page with these parameters.
JavaScript to validate WEEK2 fields of registration page.
AIM: Write JavaScript to validate the following fields of the above registration page.
Name (Name should contains alphabets and the length should not be less than 6 characters).
Password (Password should not be less than 6 characters length).
E-mail id (should not contain any invalid and must follow the standard pattern
name@domain.com)
4. Phone number (Phone number should contain 10 digits only).
DESCRIPTION:
JavaScript is a simple scripting language invented specifically for use in web browsers to
make websites more dynamic. On its own, HTML is capable of outputting more-or-less static pages.
Once you load them up your view doesn't change much until you click a link to go to a new page.
Adding JavaScript to your code allows you to change how the document looks completely, from
changing text, to changing colors, to changing the options available in a drop-down list. JavaScript is
a client-side language.
JavaScripts are integrated into the browsing environment, which means they can get
information about the browser and HTML page, and modify this information, thus changing how
things are presented on your screen. This access to information gives JavaScript great power to
modify the browsing experience. They can also react to events, such as when the user clicks their
mouse, or points to a certain page element. This is also a very powerful ability.
Regular Expressions:
One of the most common situations that come up is having an HTML form for users to enter
data. Normally, we might be interested in the visitors name, phone number and email address, and
so forth. However, even if we are very careful about putting some hints next to each required field,
some visitors are going to get it wrong, either accidentally or for malicious purposes. Heres where
regular expressions come in handy. A regular expression is a way of describing a pattern in a piece of
text. In fact, its an easy way of matching a string to a pattern. We could write a simple regular
expression and use it to check, quickly, whether or not any given string is a properly formatted user
input. This saves us from difficulties and allows us to write clean and tight code.
A regular expression is a JavaScript object. There are multiple ways of creating them. They
can be created statically when the script is first parsed or dynamically at run time. A static regular
expression is created as follows:
regx=/fish|fow1/;
Dynamic patterns are created using the keyword to create an instance of the RegExp class:
regx=new RegExp(fish|fow1);
1.
2.
3.
62
OUTPUT:
64
2) Set a background image for both the page and single elements on the page.You can define the
background
image for the page
Program:
<html>
<head>
<title>Image</title>
<style>
body
{
background-image:url("Sunset.jpg" );
background-repeat:no-repeat;
67
3) Control the repetition of the image with the background-repeat property.As background-repeat:
repeat Tiles the image until the entire page is filled, just like an ordinary background image in plain
HTML.
Program:
<html>
<head>
<title>Image</title>
<style>
body
{
background-image:url("a.jpg");
background-repeat:repeat-Y;
}
</style>
</head>
<body>HAPPY BIRTHDAY
</body>
68
69
71
Week-5: 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. Note: Give at least for 4 books. It should be valid syntactically. Hint: You
can use some xml editors like XML-spy
AIM: Write an XML file which will display the Book information.
It includes the following:
1) Title of the book
2) Author Name
3) ISBN number
4) Publisher name
5) Edition
6) Price
72
Bookstore.xml
<!DOCTYPE bookstore SYSTEM "C:\Documents and Settings\Administrator\My
Documents\bookstore.dtd">
<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>
<author>ditel&ditel</author>
<ISBN>123-456-781</ISBN>
<publisher>person</publisher>
<edition>3</edition>
<price>450</price>
</book>
</bookstore>
74
77
VISUAL BEANS: Create a simple visual bean with a area filled with a color.
The shape of the area depends on the property shape. If it is set to true then the shape of the area is
Square and it is Circle, if it is false.
The color of the area should be changed dynamically for every mouse click. The color should also be
changed if we change the color in the property window
Program 1: Colorbean.java
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.io.Serializable;
public class Colorbean extends Canvas implements Serializable
{
transient private Color color;
private boolean rectangular;
public void colorbean()
{
addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent me)
{
change();
}
});
rectangular=false;
setSize(200,100);
change();
}
public boolean getRectangular()
{
return rectangular;
}
public void setRectangular(boolean flag)
{
this.rectangular=flag;
repaint();
}
public void change()
{
color=randomColor();
repaint();
}
78
79
---80
---
82
83
1.
2.
3.
4.
5.
DESCRIPTION:
Servlet Life cycle:
Servlet class loading
Servlet Instantiation
call the init method
call the service method
call destroy method
Class loading and instantiation
If you consider a servlet to be just like any other Java program, except that it runs within a
servlet container, there has to be a process of loading the class and making it ready for requests.
Servlets do not have the exact equivalent of a main method that causes them to start execution.
When a web container starts it searches for the deployment descriptor (WEB.XML) for each
of its web applications. When it finds a servlet in the descriptor it will create an instance of the
servlet class. At this point the class is considered to be loaded (but not initialized).
The init method
The HttpServlet class inherits the init method from GenericServlet. The init method performs
a role slightly similar to a constructor in an ordinary Java program in that it allows initialization of
an instance at start up. It is called automatically by the servlet container and as it causes the
84
PROGRAM:
cologin.html:
<html>
<head>
<title> login Page </title>
<p style= "background:yellow; top:100px; left:250px; position:absolute; ">
</head>
<body>
<form ACTION="clogin">
<label> Login </label>
<input type="text" name="usr" size="20"> <br> <br>
<label> Password </label>
<input type="password" name="pwd" size="20"> <br> <br>
<input type="submit" value="submit">
</form>
</body>
</html>
cologin1.html
<html>
<head>
<title> login Page </title>
<p style= "background:yellow; top:100px; left:250px; position:absolute; ">
</head>
<body>
<form ACTION="clogin1">
<label> Login </label>
<input type="text" name="usr" size="20"> <br> <br>
<label> Password </label>
<input type="password" name="pwd" size="20"> <br> <br>
<input type="submit" value="submit">
</form>
</body>
</html>
Addcook.java:
import javax.servlet.* ;
import javax.servlet.http.*;
import java.io.*;
86
88
89
2. Read the user id and passwords entered in the Login form (week1) and authenticate with the
values (user id and passwords) available in the cookies.
If he is a valid user (i.e., user-name and password match) you should welcome him by name (username) else you should display You are not an authenticated user .
Use init-parameters to do this. Store the user-names and passwords in the webinf.xml and access
them in the servlet by using the getInitParameters() method.
home.html:
<html>
<head>
<title>Authentication</title>
</head>
<body>
<form action="ex1">
<label>Username </label>
<input type="text"size="20" name="user"><br><br>
password<input type="text" size="20" name="pwd"><br><br>
<input type="submit" value="submit">
</form>
</body>
</html>
Example1.java
import javax.servlet.*;
import java.io.*;
public class Example1 extends GenericServlet
{
private String user1,pwd1,user2,pwd2,user3,pwd3,user4,pwd4,user5,pwd5;
public void init(ServletConfig sc)
90
OUTPUT:
RESULT:
Thus the user authentication is carried out for four users by using both cookies and
getInitParameters successfully.
92
96
97
98
RESULT:
Thus a table is created and the details are entered into the table using jdbc from the
registration form successfully.
-----------------
99
request,
the HttpServletRequest;
response,
the HttpServletResponse;
100
out,
the PrintWriter (a buffered version of type JspWriter) used to send output to the
client.
JSP Scriptlets
If you want to do something more complex than insert a simple expression, JSP scriptletslet
you insert arbitrary code into the servlet method that will be built to generate the page. Scriptlets
have the following form:
<% Java Code %>
Scriptlets have access to the same automatically defined variables as expressions. So, for
example, if you want output to appear in the resultant page, you would use the out variable.
<%
String queryData = request.getQueryString();
out.println("Attached GET data: " + queryData);
%>
Note that code inside a scriptlet gets inserted exactly as written, and any static HTML
(template text) before or after a scriptlet gets converted to print statements. This means that scriptlets
need not contain complete Java statements, and blocks left open can affect the static HTML outside
of the scriptlets.
JSP Declarations
A JSP declaration lets you define methods or fields that get inserted into the main body of the
servlet class (outside of the service method processing the request). It has the following form:
<%! Java Code %>
Since declarations do not generate any output, they are normally used in conjunction with
JSP expressions or scriptlets. For example, here is a JSP fragment that prints out the number of times
the current page has been requested since the server booted (or the servlet class was changed and
reloaded):
<%! private int accessCount = 0; %>
PROGRAM:
Login.html:
<!--Home.html-->
<html> <body>
<center><h1>XYZ Company Ltd.</h1></center>
<table border="1" width="100%" height="100%">
<tr>
101
103
104
RESULT:
The user is authenticated when he submits the login form using the user name and password
from the database.
---
Week-11: Create tables in the database which contain the details of items (books in our case like
Book name, Price, Quantity, Amount)) of each category. Modify your catalogue page (week 2) in
such a way that you should connect to the database and extract data from the tables and display them
in the catalogue page using JDBC.
Extract data from the tables,display them in the catalogue page using JDBC
AIM: Extract data from the tables and display them in the catalogue page using JDBC.
DESCRIPTION:
Create tables in the database which contain the details of items (books in our case like Book
name, Price, Quantity, Amount)) of each category. Modify your catalogue page (week 2) in such a
way that you should connect to the database and extract data from the tables and display them in the
catalogue page using JDBC.
105
107
OUTPUT:
RESULT:
The data is extracted from the tables and displayed in the catalogue page using JDBC
Week-12: HTTP is a stateless protocol. Session is required to maintain the state. The user may add
some items to cart from the catalog page. He can check the cart page for the selected items. He may
visit the catalogue again and select some more items. Here our interest is the selected items should be
added to the old cart rather than a new cart. Multiple users can do the same thing at a time(i.e., from
different systems in the LAN using the ip-address instead of localhost). This can be achieved through
the use of sessions. Every user will have his own session which will be created after his successful
login to the website. When the user logs out his session should get invalidated (by using the method
session. Invalidate ( ). Modify your catalogue and cart JSP pages to achieve the above mentioned
functionality using sessions
108
Week-12: HTTP is a stateless protocol. Session is required to maintain the state. The user may add
some items to cart from the catalog page. He can check the cart pagfor the selected items. He may
visit the catalogue again and select some more items. Here our interest is the selected items should be
added to the old cart rather than a new cart. Multiple users can do the same thing at a time(i.e., from
different systems in the LAN using the ip-address instead of localhost). This can be achieved through
the use of sessions. Every user will have his own session which will be created after his successful
login to the website. When the user logs out his session should get invalidated (by using the method
session. Invalidate ( ). Modify your catalogue and cart JSP pages to achieve the above mentioned
functionality using sessions.
:HTTP protocol and session management
AIM: Modify cart JSPpage to achieve the dynamism with the HTTP protocol and
session management
DESCRIPTION:
HTTP is a stateless protocol. Session is required to maintain the state.
Methods of session Object:
There are numerous methods available for session Object. Some are:
getAttribute(String name)
getAttributeNames
isNew()
getCreationTime
getId
invalidate()
getLastAccessedTime
getMaxInactiveInterval
109
}
}
<web-app>
<servlet>
<servlet-name>Login</servlet-name>
<servlet-class>Login</servlet-class>
<init-param>
<param-name>username</param-name>
<param-value>syam</param-value>
</init-param>
<init-param>
<param-name>password</param-name>
<param-value>syam</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Login</servlet-name>
<url-pattern>/login.do</url-pattern>
112
113
114