Professional Documents
Culture Documents
Lab Manual WT
Lab Manual WT
List of Assignments
Sr. Page
Name of Assignments
No. No.
Installation and Configuration of Web Application Servers Tomcat, 2
1 Apache, WebSphere, JBoss, GlassFish.
Design and develop any suitable web application using HTML, CSS and 8
2 XML in consultation of course instructor.
Re-Design, develop and deploy assignment no. 3 of unit –III using Strut. 88
6
Re-Design, develop and deploy assignment no. 4 of unit –IV using Angular 107
7
JS.
Design, Develop and Deploy separate web application using 123
8
EJB/CMS/JSF/Spring/Bootstrap.
Subject Incharge H. O. D
Mr. Korade N.B. Mr. M. B. Salunke
Assignment No: 1
Title: TOMCAT SERVER installation.
Objectives: Understand how to install tomcat server and set up environment
variables.
Problem Statement: Installation of TOMCAT Server and Configuration of it.
Outcome: Students will be able to:
1. Install TOMCAT Server and Configuration of it .
Software & Hardware Requirments:
1. Java 7 or Later
2. Apache Tomcat Server
Theory:
1. Introduction:
In a technical sense, a server is an instance of a computer program that
accepts and responds to requests made by another program, known as a client. Less
formally, any device that runs server software could be considered a server as well.
Servers are used to manage network resources. For example, a user may setup a
server to control access to a network, send/receive e-mail, manage print jobs, or host
a website.
If the requested web page at the client side is not found, then web server will
sends the HTTP response: Error 404 Not found.
When the web server searching the requested page if requested page is found
then it will send to the client with an HTTP response.
If the client requests some other resources then web server will contact to
application server and data is store for constructing the HTTP response.
2. Apache Tomcat
Apache Tomcat, often referred to as Tomcat Server, is an open-source Java
Servlet Container developed by the Apache Software Foundation (ASF). Tomcat
implements several Java EE specifications including Java Servlet, JavaServer Pages
(JSP), Java EL, and WebSocket, and provides a "pure Java" HTTP web server
environment in which Java code can run.
4. Open Command Prompt and enter java to check Environment Variable are set
properly or not. The output is as below:
5. Now, you will see the Tomcat home page, which is provided by the Tomcat
Web server running on your computer. Open browser Mozilla or Google
Chrome and enter URL as : http://localhost:8080/
1. The first thing you will want to do is update your apt-get package lists:
$sudo apt-get update
2. Now you are ready to install Tomcat. Run the following command to start the
installation:
$sudo apt-get install tomcat7
3. Answer yes at the prompt to install tomcat. This will install Tomcat and its
dependencies, such as Java, and it will also create the tomcat7 user. It also starts
Tomcat with its default settings.
4. Let's make a quick change to the Java options that Tomcat uses when it starts.
Open the Tomcat7 parameters file:
$sudo nano /etc/default/tomcat7
5. Find the JAVA_OPTS line and replace it with the following. Feel free to change the
Xmx and MaxPermSize values—these settings affect how much memory Tomcat will
use:
/etc/default/tomcat7 — JAVA_OPTS
#JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -
Djava.awt.headless=true -Xmx512m -XX:MaxPermSize=256m -
XX:+UseConcMarkSweepGC"
<tomcat-users>
...
</tomcat-users>
10.3 You will want to add a user who can access the manager-gui and admin-gui (the
management interface that we installed in Step Three). You can do so by defining a
user similar to the example below. Be sure to change the username and password to
something secure:
<tomcat-users>
<user username="admin" password="password" roles="manager-
gui,admin-gui"/>
</tomcat-users>
10.4 Save and quit the tomcat-users.xml file. To put our changes into effect, restart
the Tomcat service:
$sudo service tomcat7 restart
Conclusion:
Hence, we have learned how to install and configure tomcat server.
FAQs:
1. What is Tomcat?
2. What is the tomcat default port?
3. What services are provided by Tomcat?
4. Explain directory structure of tomcat.
5. How to stop/start Apache Web Server?
6. How to check the version of running Apache Web Server?
7. How To We Can Change Tomcat Default Port?
8. Explain Directory Structure Of Tomcat?
9. Explain What Is Tomcat Valve?
10. Explain what is Jasper?
Assignment No: 2
Title: Web Development Using HTML, CSS, XML.
Objectives:
1. Understand about basic concepts of html
2. Understand the basic concepts of XML
3. Understand the basic concepts of CSS
Problem Statement: Design and develop any suitable web application using HTML, CSS
and XML in consultation of course instructor.
Outcome: Students will be able to:
1. Design static webpage using HTML.
2. Apply CSS to HTML pages.
3. Use XML for Data Storage
Software & Hardware Requirments:
1. Notepad/Notepad++
2. Browser(Google Chrome/Internet Explorer)
Theory:
1. HTML:
HTML stands for Hyper Text Markup Language, which is the most widely used language
on Web to develop web pages. HTML was created by Berners-Lee in late 1991 but "HTML
2.0" was the first standard HTML specification which was published in 1995. HTML 4.01
was a major version of HTML and it was published in late 1999. Though HTML 4.01 version
is widely used but currently we are having HTML-5 version which is an extension to HTML
4.01, and this version was published in 2012.
Hypertext refers to the way in which Web pages (HTML documents) are linked
together. Thus, the link available on a webpage is called Hypertext.
As its name suggests, HTML is a Markup Language which means you use HTML to
simply "mark-up" a text document with tags that tell a Web browser how to structure
it to display.
1.1 Basic HTML Document
<!DOCTYPE html>
<html>
<head>
<title>This is document
title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>Document content goes
here.....</p>
</body>
</html>
<!DOCTYPE...> This tag defines the document type and HTML version.
<html> This tag encloses the complete HTML document and mainly comprises of
document header which is represented by <head>...</head> and document body which is
represented by <body>...</body> tags.
<head> This tag represents the document's header which can keep other HTML tags like
<title>, <link> etc.
<title> The <title> tag is used inside the <head> tag to mention the document title.
<body> This tag represents the document's body which keeps other HTML tags like <h1>,
<div>, <p> etc.
1.4 Fonts
The font tag is having three attributes called size, color, and face to customize your fonts. To
change any of the font attributes at any time within your webpage, simply use the <font> tag.
The text that follows will remain changed until you close with the </font> tag. You can
change one or all of the font attributes within one <font> tag.
2. CSS
2.1 What is CSS?
CSS stands for Cascading Style Sheets
CSS describes how HTML elements are to be displayed on screen, paper, or in
other media
CSS saves a lot of work. It can control the layout of multiple web pages all at once
External stylesheets are stored in CSS files
CSS is used to define styles for your web pages, including the design, layout and
variations in display for different devices and screen sizes.
<!DOCTYPE html>
<html>
<head>
<style>
#para1 {
text-align: center;
color: red;
}
</style>
</head>
<body>
<p id="para1">Hello World!</p>
<p>This paragraph is not affected
by the style.</p>
</body>
</html>
<!DOCTYPE html>
<html><head>
<style>
.center {
text-align: center;
color: red;
}
</style>
</head>
<body>
<h1 class="center">Red and center-
aligned heading</h1>
<p class="center">Red and center-
aligned paragraph.</p>
</body></html>
2.4 Types:
2.4.1 External Style Sheet:
With an external style sheet, you can change the look of an entire website by changing just
one file. An external style sheet can be written in any text editor. The file should not contain
any html tags. The style sheet file must be saved with a .css extension. Each page must
include a reference to the external style sheet file inside the <link> element. The <link>
element goes inside the <head> section:
mystyle.css
body {
background-color:
lightblue;
}
h1 {
color: navy;
margin-left: 20px;
}
<html>
<head>
<link rel="stylesheet"
type="text/css" href="mystyle.css">
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
3. XML
XML stands for Extensible Markup Language and is a text-based markup language
derived from Standard Generalized Markup Language (SGML).
XML is extensible − XML allows you to create your own self-descriptive tags, or
language, that suits your application.
XML carries the data, does not present it − XML allows you to store the data
irrespective of how it will be presented.
XML is a public standard − XML was developed by an organization called the
World Wide Web Consortium (W3C) and is available as an open standard.
The XML declaration strictly needs be the first statement in the XML
document.
An HTTP protocol can override the value of encoding that you put in the XML
declaration.
3. All XML Elements Must Have a Closing Tag :In HTML, some elements might
work well, even with a missing closing tag, In XML, it is illegal to omit the closing
tag. All elements must have a closing tag.
4. XML Tags are Case Sensitive : XML tags are case sensitive. The tag <Letter> is
different from the tag <letter>. Opening and closing tags must be written with
the same case
5. XML Elements Must be Properly Nested: In HTML, you might see improperly
nested elements:
<b><i>This text is bold and
italic</b></i>
XML Elements Must be Properly Nested.
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this
weekend!</body>
</note>
6. XML Attribute Values Must be Quoted :XML elements can have attributes in
name/value pairs just like in HTML. In XML, the attribute values must always be
quoted.
<note date="12/11/2007">
<to>Tove</to>
<from>Jani</from>
</note>
7. Entity References : Some characters have a special meaning in XML. If you place a
character like "<" inside an XML element, it will generate an error because the parser
interprets it as the start of a new element.
<message>salary < 1000</message>
There are 5 pre-defined entity references in XML:
< < less than
8. Comments in XML : The syntax for writing comments in XML is similar to that of
HTML.
<!-- This is a comment -->
Conclusion:
Hence, we have designed static web pages using HTML, CSS and CSS.
Program
1. style.css
body
{
background-image: url("img.jpeg");
background-repeat: no-repeat;
background-size: cover;
}
a
{
margin: 100px 0 0 36px;
}
.login
{
border: 2px solid;
border-radius: 5px;
height: 200px;
margin: 150px 0 auto 400px;
width: 310px;
border-color:#3498DB;
padding-top: 20px;
}
.register
{
border: 2px solid;
border-radius: 5px;
height: 350px;
margin: 150px 0 auto 400px;
width: 310px;
border-color:#3498DB;
padding-top: 20px;
}
input[type="password"], input[type="text"]
{
border:1px solid;
background-color:rgba(0,0,0,0.0);
height: 33px;
width:240px;
margin: 2px 0 0 36px;
padding-left: 10px;
}
input[type="submit"]
{
background-color: #4CAF50;
color: white;
height: 42px;
margin: 10px 0 0 36px;
width: 250px;
padding-left: 10px;
}
input[type="submit"]:hover
{
background-image: linear-gradient(#4ec7c0,#31aba3)
}
input[type="submit"]:active
{
background-image: linear-gradient(#319d91, #3db0a6);
padding: 0;
}
2. login.html
<!DOCTYPE html>
<html>
<head>
<link rel = "stylesheet" type = "text/css" href = "style.css" />
</head>
<body>
<div class="login">
<form action="" name="myform" onsubmit="loadDoc()" method="post">
<label><b>Username</b></label>
<input type="text" name="username" id="username" placeholder=
"Username" required="required" onfocus="this.value = '';">
<label><b>Password</b></label>
<input type="password" name="password" id="password"
placeholder="password" required="required" onfocus="this.value =
'';">
<input type="submit" value="Login">
<a href="register.html"> Register Yourself</a>
</form>
</div>
<script>
function loadDoc()
{
//document.write("2");
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function()
{
if (this.readyState == 4 && this.status == 200)
{
myFunction(this);
}
};
xhttp.open("GET", "database.xml", true);
xhttp.send();
}
function myFunction(xml)
{
//document.write("1");
var i;
var flag=0;
var xmlDoc = xml.responseXML;
var username = document.getElementById("username").value;
var userpass = document.getElementById("password").value;
//document.write("Username "+username+" password "+userpass+"
");
var x = xmlDoc.getElementsByTagName("account");
// document.write(x.length);
for (i = 0; i <x.length; i++)
{
var
name=x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue;
var
pass=x[i].getElementsByTagName("pass")[0].childNodes[0].nodeValue;
}
else
{
flag=1;
}
}
if(flag==1)
{
window.location="home.html";
}
else
{
document.write(" <a href=\"login.html\"> Login again </a>
Username password wrong....");
}
}
</script>
</body>
</html>
3. home.html
<!DOCTYPE html>
<html>
<body>
<center><h2> <font color="red">Welcome to Course Consultation
Website</h2></font>
<table border="1">
<tr>
<th>Qualification</th>
<th>Intrest</th>
<th>Course Suggestion</th>
</tr>
<tr>
<td>12th</td>
<td>Programming</td>
<td>C,C++</td>
</tr>
<tr>
<td>12th</td>
<td>Web Design</td>
<td>HTML,CSS,JavaScript</td>
</tr>
<tr>
<td>12th</td>
<td>Car Design</td>
<td>AutoCAD, CATIA</td>
</tr>
<tr>
<td>12th</td>
<td>Robotics</td>
<td>Artificial Intelligence and Robotics</td>
</tr>
</table>
</center>
</body>
</html>
4. register.html
<!DOCTYPE html>
<html>
<head>
<link rel = "stylesheet" type = "text/css" href = "style.css" />
</head>
<body>
<div class="register">
<form action="addentry.php" name="myform" method="post">
<label><b>Username</b></label>
<input type="text" name="username" id="username" placeholder=
"Username" required="required" onfocus="this.value = '';">
<label><b>Password</b></label>
<input type="password" name="password" id="password"
placeholder="password" required="required" onfocus="this.value =
'';">
<label><b>Mobile Number</b></label>
<input type="text" name="mobile" id="mobile" placeholder= "Mobile
Number" required="required" onfocus="this.value = '';">
<label><b>E-Mail Address</b></label>
<input type="text" name="email" id="email" placeholder= "E-Mail
Address" required="required" onfocus="this.value = '';">
<label><b>Age</b></label>
<input type="text" name="age" id="age" placeholder= "Age"
required="required" onfocus="this.value = '';">
</form>
</body>
</html>
5. addentry.php
<?php
$xmldoc = new DomDocument( '1.0' );
$xmldoc->preserveWhiteSpace = false;
$xmldoc->formatOutput = true;
$name = $_POST['username'];
$pass = $_POST['password'];
$mobile = $_POST['mobile'];
$email = $_POST['email'];
$age = $_POST['age'];
$passElement = $xmldoc->createElement('pass');
$account->appendChild($passElement);
$passText = $xmldoc->createTextNode($pass);
$passElement->appendChild($passText);
$emailElement = $xmldoc->createElement('email');
$account->appendChild($emailElement);
$emailText = $xmldoc->createTextNode($email);
$emailElement->appendChild($emailText);
$mobileElement = $xmldoc->createElement('mobile');
$account->appendChild($mobileElement);
$mobileText = $xmldoc->createTextNode($mobile);
$mobileElement->appendChild($mobileText);
$ageElement = $xmldoc->createElement('age');
$account->appendChild($ageElement);
$ageText = $xmldoc->createTextNode($age);
$ageElement->appendChild($ageText);
$xmldoc->save('database.xml');
}
?>
<html>
<body>
<h2>You are Successfully Register please<a href="login.html">go to
Login page</a></h2>
</body>
</html>
6. database.xml
<?xml version="1.0"?>
<users>
<profile>
<account>
<name>nilesh</name>
<pass>nilesh</pass>
<email>nil@gmail.com</email>
<mobile>8989898989</mobile>
<age>27</age>
</account>
<account>
<name>vivek</name>
<pass>vivek</pass>
<email>viv@gmail.com</email>
<mobile>9090909090</mobile>
<age>21</age>
</account>
</profile>
</users>
OutPut:
1. Login
2. Home Page
3. Registration Page
FAQs:
1. What is the difference between HTML and HTML5?
2. What is the difference between html elements and tags?
3. What is marquee?
4. What is the use of span tag? Give an example?
5. What is the use of ‘required ’attribute in HTML5?
6. What is External stylesheet? What are the advantages and disadvantages?
7. What is CSS selector?
8. What are the components of CSS style?
9. What is browser safe color?
10. Explain difference between HTML and XML?
11. What is XML DOM?
12. Explain difference between CDATA and PCDATA?
13. What is mean by simple element and complex element?
14. What is XPATH?
15. Explain XSL and XSLT?
Assignment No: 3
Title: Validation using JavaScript.
Objectives:
1. Understand about basic concepts of JavaScript.
2. Use JavaScript for validation of data.
Problem Statement: Perform validation of all fields in Assignment no.1 by using Java
script/JQuery.
Outcome: Students will be able to:
1. Design static webpage using HTML,CSS.
2. Apply JavaScript to HTML pages for validation of data.
Software & Hardware Requirments:
1. Notepad/Notepad++
2. Browser(Google Chrome)
Theory:
1. JavaScript
1. 1. History
JavaScript is a lightweight, interpreted programming language. It is designed for
creating network-centric applications. It is complimentary to and integrated with Java.
JavaScript is very easy to implement because it is integrated with HTML. It is open and
cross-platform.
JavaScript is a dynamic computer programming language. It is lightweight and most
commonly used as a part of web pages, whose implementations allow client-side script to
interact with the user and make dynamic pages. It is an interpreted programming language
with object-oriented capabilities.
JavaScript was first known as LiveScript, but Netscape changed its name to
JavaScript, possibly because of the excitement being generated by Java. JavaScript made its
first appearance in Netscape 2.0 in 1995 with the name LiveScript.
The general-purpose core of the language has been embedded in Netscape, Internet
Explorer, and other web browsers.
JavaScript is a lightweight, interpreted programming language.
Designed for creating network-centric applications.
Complementary to and integrated with Java.
Complementary to and integrated with HTML.
Open and cross-platform
1. 2. Limitations
Client-side JavaScript does not allow the reading or writing of files. This has been
kept for security reason.
JavaScript cannot be used for networking applications because there is no such
support available.
JavaScript doesn't have any multithreading or multiprocessor capabilities.
1.3. </script>
JavaScript can be implemented using JavaScript statements that are placed within the
<script>... </script> HTML tags in a web page.
You can place the <script> tags, containing your JavaScript, anywhere within
you web page, but it is normally recommended that you should keep it within the
<head> tags.
Type − This attribute is what is now recommended to indicate the scripting language
in use and its value should be set to "text/javascript"
1.4. Example
<html>
<body>
<script language="javascript" type="text/javascript">
<!--
document.write("Hello World!")
//-->
</script>
</body>
</html>
The comment ends with a "//-->". Here "//" signifies a comment in JavaScript, so we
add that to prevent a browser from reading the end of the HTML comment as a piece of
JavaScript code. Next, we call a function document.write which writes a string into our
HTML document.
This function can be used to write text, HTML, or both.
1. 8. Comments in JavaScript
JavaScript supports both C-style and C++-style comments, Thus −
Any text between a // and the end of a line is treated as a comment and is ignored by
JavaScript.
Any text between the characters /* and */ is treated as a comment. This may span
multiple lines.
JavaScript also recognizes the HTML comment opening sequence <!--. JavaScript
treats this as a single-line comment, just as it does the // comment.
The HTML comment closing sequence --> is not recognized by JavaScript so it
should be written as //-->.
<body>
<script type="text/javascript">
<!--
document.write("Hello World")
//-->
</script>
</body>
</html>
function sayHello()
{
alert("Hello World") //filename.js
}
<html>
<head>
<script type="text/javascript" src="filename.js" ></script>
</head>
<body>
< input type="button" onclick="sayHello()" value="Say Hello" /> </body>
</html>
1.10 Variables
One of the most fundamental characteristics of a programming language is the set of
data types it supports. These are the type of values that can be represented and manipulated in
a programming language.
JavaScript allows you to work with three primitive data types −
Numbers, eg. 123, 120.50 etc.
Strings of text e.g. "This text string" etc.
Boolean e.g. true or false.
Note − Java does not make a distinction between integer values and floating-point values. All
numbers in JavaScript are represented as floating-point values.
You can also declare multiple variables with the same var keyword as follows −
<script type="text/javascript">
<!--
var money, name;
//-->
</script>
JavaScript is untyped language. This means that a JavaScript variable can hold a
value of any data type. Unlike many other languages, you don't have to tell JavaScript during
variable declaration what type of value the variable will hold. The value type of a variable
can change during the execution of a program and JavaScript takes care of it automatically.
1.11 Functions
Before we use a function, we need to define it. The most common way to define a function in
JavaScript is by using the function keyword, followed by a unique function name, a list of
parameters (that might be empty), and a statement block surrounded by curly braces.
<html>
<head>
<script type="text/javascript">
function sayHello()
{
document.write ("Hello there!");
}
</script>
</head>
<body>
<p>Click the following button to call the function</p>
<form>
<input type="button" onclick="sayHello()" value="Say Hello">
</form>
<html>
<head>
<script type="text/javascript">
function concatenate(first, last)
{
var full;
full = first + last;
return full;
}
function secondFunction()
{
var result;
result = concatenate('Zara', 'Ali');
document.write (result );
}
</script>
</head>
<body>
<p>Click the following button to call the function</p>
<form>
<input type="button" onclick="secondFunction()" value="Call Function">
</form>
</body>
</html>
1.12 Events
JavaScript's interaction with HTML is handled through events that occur when the user or the
browser manipulates a page.
When the page loads, it is called an event. When the user clicks a button, that click too is an
event. Other examples include events like pressing any key, closing a window, resizing a
window, etc.
<html>
<head>
<script type="text/javascript">
function sayHello()
{
alert("Hello World")
}
</script>
</head>
<body>
<p>Click the following button and see result</p>
<form>
<input type="button" onclick="sayHello()" value="Say Hello" />
</form>
</body>
</html>
Conclusion:
Hence, we have learned how to use JavaScript for validation.
Program
1. style.css
body
{
background-image: url("img.jpeg");
background-repeat: no-repeat;
background-size: cover;
}
a
{
margin: 100px 0 0 36px;
}
.login
{
border: 2px solid;
border-radius: 5px;
height: 200px;
margin: 150px 0 auto 400px;
width: 310px;
border-color:#3498DB;
padding-top: 20px;
}
.register
{
border: 2px solid;
border-radius: 5px;
height: 350px;
margin: 150px 0 auto 400px;
width: 310px;
border-color:#3498DB;
padding-top: 20px;
}
input[type="password"], input[type="text"]
{
border:1px solid;
background-color:rgba(0,0,0,0.0);
height: 33px;
width:240px;
margin: 2px 0 0 36px;
padding-left: 10px;
}
input[type="submit"]
{
background-color: #4CAF50;
color: white;
height: 42px;
margin: 10px 0 0 36px;
width: 250px;
padding-left: 10px;
}
input[type="submit"]:hover
{
background-image: linear-gradient(#4ec7c0,#31aba3)
}
input[type="submit"]:active
{
background-image: linear-gradient(#319d91, #3db0a6);
padding: 0;
}
2. login.html
<!DOCTYPE html>
<html>
<head>
<link rel = "stylesheet" type = "text/css" href = "style.css" />
</head>
<body>
<div class="login">
<form action="" name="myform" onsubmit="loadDoc()" method="post">
<label><b>Username</b></label>
<input type="text" name="username" id="username" placeholder=
"Username" required="required" onfocus="this.value = '';">
<label><b>Password</b></label>
<input type="password" name="password" id="password"
placeholder="password" required="required" onfocus="this.value =
'';">
<input type="submit" value="Login">
<a href="register.html"> Register Yourself</a>
</form>
</div>
<script>
function loadDoc()
{
//document.write("2");
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function()
{
if (this.readyState == 4 && this.status == 200)
{
myFunction(this);
}
};
xhttp.open("GET", "database.xml", true);
xhttp.send();
}
function myFunction(xml)
{
//document.write("1");
var i;
var flag=0;
var xmlDoc = xml.responseXML;
var username = document.getElementById("username").value;
var userpass = document.getElementById("password").value;
//document.write("Username "+username+" password "+userpass+"
");
var x = xmlDoc.getElementsByTagName("account");
// document.write(x.length);
for (i = 0; i <x.length; i++)
{
var
name=x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue;
var
pass=x[i].getElementsByTagName("pass")[0].childNodes[0].nodeValue;
}
else
{
flag=1;
}
}
if(flag==1)
{
window.location="home.html";
}
else
{
document.write(" <a href=\"login.html\"> Login again </a>
Username password wrong....");
}
}
</script>
</body>
</html>
3. home.html
<!DOCTYPE html>
<html>
<body>
<center><h2> <font color="red">Welcome to Course Consultation
Website</h2></font>
<table border="1">
<tr>
<th>Qualification</th>
<th>Intrest</th>
<th>Course Suggestion</th>
</tr>
<tr>
<td>12th</td>
<td>Programming</td>
<td>C,C++</td>
</tr>
<tr>
<td>12th</td>
<td>Web Design</td>
<td>HTML,CSS,JavaScript</td>
</tr>
<tr>
<td>12th</td>
<td>Car Design</td>
<td>AutoCAD, CATIA</td>
</tr>
<tr>
<td>12th</td>
<td>Robotics</td>
<td>Artificial Intelligence and Robotics</td>
</tr>
</table>
</center>
</body>
</html>
4. register.html
<!DOCTYPE html>
<html>
<head>
<link rel = "stylesheet" type = "text/css" href = "style.css" />
<script type="text/javascript">
function validateform()
{
var pass=document.myform.password.value;
if(pass.length<4)
{
alert("Enter Password At Least 4 Charactor");
return false;
}
var mobile=document.myform.mobile.value;
if(isNaN(mobile))
{
alert("Enter Digit Only in Mobile Number");
return false;
}
else if (mobile.length<10||mobile.length>10)
{
alert("Enter Mobile Number 10 Digit Only");
return false;
}
var email = document.myform.email.value;
var atpos = email.indexOf("@");
var dotpos = email.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=email.length)
{
alert("Not a valid e-mail address");
return false;
}
var age=document.myform.age.value;
if(isNaN(age))
{
alert("Enter Digit Only in Age");
return false;
}
return true;
}
</script>
</head>
<body>
<div class="register">
<form action="addentry.php" name="myform" onsubmit="return
validateform()" method="post">
<label><b>Username</b></label>
<input type="text" name="username" id="username" placeholder=
"Username" required="required" onfocus="this.value = '';">
<label><b>Password</b></label>
</form>
</body>
</html>
5. addentry.php
<?php
$xmldoc = new DomDocument( '1.0' );
$xmldoc->preserveWhiteSpace = false;
$xmldoc->formatOutput = true;
$name = $_POST['username'];
$pass = $_POST['password'];
$mobile = $_POST['mobile'];
$email = $_POST['email'];
$age = $_POST['age'];
$passElement = $xmldoc->createElement('pass');
$account->appendChild($passElement);
$passText = $xmldoc->createTextNode($pass);
$passElement->appendChild($passText);
$emailElement = $xmldoc->createElement('email');
$account->appendChild($emailElement);
$emailText = $xmldoc->createTextNode($email);
$emailElement->appendChild($emailText);
$mobileElement = $xmldoc->createElement('mobile');
$account->appendChild($mobileElement);
$mobileText = $xmldoc->createTextNode($mobile);
$mobileElement->appendChild($mobileText);
$ageElement = $xmldoc->createElement('age');
$account->appendChild($ageElement);
$ageText = $xmldoc->createTextNode($age);
$ageElement->appendChild($ageText);
$xmldoc->save('database.xml');
}
?>
<html>
<body>
<h2>You are Successfully Register please<a href="login.html">go to
Login page</a></h2>
</body>
</html>
6. database.xml
<?xml version="1.0"?>
<users>
<profile>
<account>
<name>nilesh</name>
<pass>nilesh</pass>
<email>nil@gmail.com</email>
<mobile>8989898989</mobile>
<age>27</age>
</account>
<account>
<name>vivek</name>
<pass>vivek</pass>
<email>viv@gmail.com</email>
<mobile>9090909090</mobile>
<age>21</age>
</account>
</profile>
</users>
OutPut:
1. login
2. Home Page
3. Registration
FAQs:
1. Explain feature of JavaScript?
2. Explain how to define JavaScript in external file?
3. Explain how to define function in JavaScript?
4. What are the default objects available in JavaScript?
5. Explain advantages and limitation of JavaScript?
6. What is event in JavaScript? Explain with example?
7. Which dialog boxes available in JavaScript?
8. How to find HTML Elements using JavaScript?
Assignment No: 4
Title: Web Development using JSP, Servlet and MySQL(Backend).
Objectives:
1. Understand about basic concepts of Servlet & JSP
2. Having the knowledge of SQL query to create the database
Problem Statement: Add dynamic web application essence in assignment no. 2 using
Servlet, JSP and backend.
Theory:
1. Servlet
Java Servlets are programs that run on a Web or Application server and act as a
middle layer between a request coming from a Web browser or other HTTP client and
databases or applications on the HTTP server. Using Servlets, you can collect input from
users through web page forms, present records from a database or another source, and create
web pages dynamically. Java Servlets often serve the same purpose as programs implemented
using the Common Gateway Interface (CGI).
1.3 Examples
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
2. JavaServer Pages.
JavaServer Pages (JSP) is a technology for developing web pages that support
dynamic content which helps developers insert java code in HTML pages by making use of
special JSP tags, most of which start with <% and end with %>.
A JavaServer Pages component is a type of Java servlet that is designed to fulfill the
role of a user interface for a Java web application. Web developers write JSPs as text files
that combine HTML or XHTML code, XML elements, and embedded JSP actions and
commands.
Using JSP, you can collect input from users through web page forms, present records
from a database or another source, and create web pages dynamically.
JSP tags can be used for a variety of purposes, such as retrieving information from a
database or registering user preferences, accessing JavaBeans components, passing control
between pages and sharing information between requests, pages etc.
JSP are always compiled before it's processed by the server unlike CGI/Perl which
requires the server to load an interpreter and the target script each time the page is
requested.
JavaServer Pages are built on top of the Java Servlets API, so like Servlets, JSP also
has access to all the powerful Enterprise Java APIs, including JDBC, JNDI, EJB,
JAXP etc.
JSP pages can be used in combination with servlets that handle the business logic, the
model supported by Java servlet template engines.
Finally, JSP is an integral part of Java EE, a complete platform for enterprise class
applications. This means that JSP can play a part in the simplest applications to the
most complex and demanding.
JSP Processing:
The following steps explain how the web server creates the web page using JSP:
As with a normal page, your browser sends an HTTP request to the web server.
The web server recognizes that the HTTP request is for a JSP page and forwards it to
a JSP engine. This is done by using the URL or JSP page which ends with .jsp instead
of .html.
The JSP engine loads the JSP page from disk and converts it into a servlet content.
This conversion is very simple in which all template text is converted to println( )
statements and all JSP elements are converted to Java code that implements the
corresponding dynamic behavior of the page.
The JSP engine compiles the servlet into an executable class and forwards the original
request to a servlet engine.
A part of the web server called the servlet engine loads the Servlet class and executes
it. During execution, the servlet produces an output in HTML format, which the
servlet engine passes to the web server inside an HTTP response.
The web server forwards the HTTP response to your browser in terms of static HTML
content.
Finally web browser handles the dynamically generated HTML page inside the HTTP
response exactly as if it were a static page.
All the above mentioned steps can be shown below in the following diagram:
Typically initialization is performed only once and as with the servlet init method,
you generally initialize database connections, open files, and create lookup tables in the
jspInit method.
The _jspService() method of a JSP is invoked once per a request and is responsible
for generating the response for that request and this method is also responsible for generating
responses to all seven of the HTTP methods ie. GET, POST, DELETE etc.
Any text, HTML tags, or JSP elements you write must be outside the scriptlet.
Following is the simple and first example for JSP:
<html>
<head><title>Hello World</title></head>
<body>
Hello World!<br/>
<%
out.println("Your IP address is " + request.getRemoteAddr());
%>
</body>
</html>
Conclusion:
Hence, we have developed the dynamic web application using JSP, Servlet and MySQL.
Program:
Project Structure
1. style.css
body
{
background-image: url("img.jpeg");
background-repeat: no-repeat;
background-size: cover;
}
a
{
margin: 100px 0 0 36px;
}
.login
{
border: 2px solid;
border-radius: 5px;
height: 200px;
margin: 150px 0 auto 400px;
width: 310px;
border-color:#3498DB;
padding-top: 20px;
}
.register
{
border: 2px solid;
border-radius: 5px;
height: 350px;
margin: 150px 0 auto 400px;
width: 310px;
border-color:#3498DB;
padding-top: 20px;
}
input[type="password"], input[type="text"]
{
border:1px solid;
background-color:rgba(0,0,0,0.0);
height: 33px;
width:240px;
margin: 2px 0 0 36px;
padding-left: 10px;
}
input[type="submit"]
{
background-color: #4CAF50;
color: white;
height: 42px;
margin: 10px 0 0 36px;
width: 250px;
padding-left: 10px;
}
input[type="submit"]:hover
{
background-image: linear-gradient(#4ec7c0,#31aba3)
}
input[type="submit"]:active
{
background-image: linear-gradient(#319d91, #3db0a6);
padding: 0;
}
2. index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel = "stylesheet" type = "text/css" href = "style.css" />
</head>
<body>
<div class="login">
<form action="LoginValidate" name="myform" method="post">
<label><b>Username</b></label>
<input type="text" name="username" id="username" placeholder=
"Username" required="required" onfocus="this.value = '';">
<label><b>Password</b></label>
<input type="password" name="password" id="password"
placeholder="password" required="required" onfocus="this.value =
'';">
<input type="submit" value="Login">
<a href="register.jsp"> Register Yourself</a>
</form>
</div>
</body>
</html>
3. DBConnection.java
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class DBConnection
{
public boolean verify(String user,String pass)
{
boolean flag=false;
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost/tecomp","roo
t","root");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from
login");
while(rs.next())
{
String Dname= rs.getString("username");
String Dpass=rs.getString("password");
if(user.equals(Dname) && pass.equals(Dpass))
{
flag=true;
break;
}
}
con.close();
}
catch (Exception e)
{
e.printStackTrace();
}
if(flag==true)
return true;
else
return false;
}
}
4. LoginValidate.java
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/LoginValidate")
public class LoginValidate extends HttpServlet
{
String UserName=request.getParameter("username");
String Password=request.getParameter("password");
//out.println("Username :"+UserName);
//out.println("<br>Pass:"+Password);
DBConnection d=new DBConnection();
if(d.verify(UserName, Password))
{
RequestDispatcher
rd=request.getRequestDispatcher("Home.jsp");
rd.forward(request, response);
}
else
{
out.println("<b><center>Username or Password is
Wrong Please Retry</center></b>");
RequestDispatcher
rd=request.getRequestDispatcher("index.html");
rd.include(request, response);
}
}
}
5. Home.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<center><h2> <font color="red">Welcome to Course Consultation
Website</h2></font>
<table border="1">
<tr>
<th>Qualification</th>
<th>Intrest</th>
<th>Course Suggestion</th>
</tr>
<tr>
<td>12th</td>
<td>Programming</td>
<td>C,C++</td>
</tr>
<tr>
<td>12th</td>
<td>Web Design</td>
<td>HTML,CSS,JavaScript</td>
</tr>
<tr>
<td>12th</td>
<td>Car Design</td>
<td>AutoCAD, CATIA</td>
</tr>
<tr>
<td>12th</td>
<td>Robotics</td>
<td>Artificial Intelligence and Robotics</td>
</tr>
</table>
</center>
</body>
</html>
6. Register.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel = "stylesheet" type = "text/css" href = "style.css" />
</head>
<body>
<div class="register">
<form action="addDataTodatabase.jsp" name="myform" onsubmit="return
validateform()" method="post">
<label><b>Username</b></label>
<input type="text" name="username" id="username" placeholder=
"Username" required="required" onfocus="this.value = '';">
<br> <label><b>Password</b></label>
<input type="password" name="password" id="password"
placeholder="password" required="required" onfocus="this.value =
'';">
<br><label><b>Mobile Number</b></label>
<input type="text" name="mobile" id="mobile" placeholder= "Mobile
Number" required="required" onfocus="this.value = '';">
<br><label><b>E-Mail Address</b></label>
<input type="text" name="email" id="email" placeholder= "E-Mail
Address" required="required" onfocus="this.value = '';">
<br><label><b>Age</b></label>
<input type="text" name="age" id="age" placeholder= "Age"
required="required" onfocus="this.value = '';">
</form>
</body>
</html>
7. addDataTodatabase.jsp
<%@page import="java.sql.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
boolean flag=false;
String username =request.getParameter("username");
String password =request.getParameter("password");
String mobile =request.getParameter("mobile");
String email =request.getParameter("email");
String age =request.getParameter("age");
Class.forName("com.mysql.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost/tecomp","roo
t","root");
Statement stmt=con.createStatement();
int i=stmt.executeUpdate("insert into login
values('"+username+"','"+password+"','"+mobile+"','"+email+"','"+age
+"')");
if(i>0)
{
//out.println("<b><font color=\"Red\"> You Have Register
Successfully <a href=\"index.html\">goto Login Page");
response.sendRedirect("index.html");
}
%>
</body>
</html>
Output:
1. Login Page
2. Home Page
3. Registration Page
4. Database
FAQs:
1. What is JSP?
2. What is Servlet?
3. What is the purpose of MySQL?
4. What is database?
5. What is the syntax of JSP?
6. How do we connect JSP file to database?
7. Explain life cycle of servlet?
8. What is session management?
9. Explain advantages of JSP over Servlet?
10. Explain Scriptlet, Expression, Declaration tag in JSP?
11. List default object in JSP?
Assignment No: 5
Title: web application using PHP, AJAX and MySQL.
Objectives To understand the principles and methodologies of web based applications
development process.
Problem Statement: Add dynamic web application essence in assignment no. 2 using PHP,
MySQL database connectivity and AJAX controls.
Outcome: Students should be able to,
1. Develop web based application using suitable client side and server side web
technologies.
2. Develop solution to complex problems using appropriate method, technologies,
frameworks, web services and content management.
Theory:
1. PHP
The PHP Hypertext Preprocessor (PHP) is a programming language that allows web
developers to create dynamic content that interacts with databases. PHP is basically used for
developing web based software applications.
1.1 Introduction
PHP started out as a small open source project that evolved as more and more people
found out how useful it was. Rasmus Lerdorf unleashed the first version of PHP way
back in 1994.
PHP is a recursive acronym for "PHP: Hypertext Preprocessor".
PHP is a server side scripting language that is embedded in HTML. It is used to
manage dynamic content, databases, session tracking, even build entire e-commerce
sites.
It is integrated with a number of popular databases, including MySQL, PostgreSQL,
Oracle, Sybase, Informix, and Microsoft SQL Server.
PHP supports a large number of major protocols such as POP3, IMAP, and LDAP.
PHP4 added support for Java and distributed object architectures (COM and
CORBA), making n-tier development a possibility for the first time.
1.2 Features
PHP Syntax is C-Like.
PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
PHP is compatible with almost all servers used today (Apache, IIS, etc.)
PHP supports a wide range of databases
PHP is free. Download it from the official PHP resource: www.php.net
PHP is easy to learn and runs efficiently on the server side
PHP can generate dynamic page content
PHP can create, open, read, write, delete, and close files on the server
PHP can collect form data
PHP can send and receive cookies
PHP can add, delete, modify data in your database
PHP can be used to control user-access
PHP can encrypt data
PHP has a total of eight data types which we use to construct our variables −
Integers − are whole numbers, without a decimal point, like 4195.
Doubles − are floating-point numbers, like 3.14159 or 49.1.
Booleans − have only two possible values either true or false.
NULL − is a special type that only has one value: NULL.
Strings − are sequences of characters, like 'PHP supports string operations.'
Arrays − are named and indexed collections of other values.
Objects − are instances of programmer-defined classes, which can package up both
other kinds of values and functions that are specific to the class.
Resources − are special variables that hold references to resources external to PHP
(such as database connections).
<?php
$many = 2.2888800;
$many_2 = 2.2111200;
$few = $many + $many_2;
print("$many + $many_2 = $few <br>");
?>
echo MINSIZE;
echo constant("MINSIZE"); // same thing as the previous line
?>
</body>
</html>
PHP Functions - Returning values :To let a function return a value, use the return
statement.
<?php
function sum($x, $y)
{
$z = $x + $y;
return $z;
}
<?php
$dbhost = 'localhost:3036';
$dbuser = 'guest';
$dbpass = 'guest123';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn ) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($conn);
?>
Data can be entered into MySQL tables by executing SQL INSERT statement through PHP
function mysql_query.
<?php
$dbhost = 'localhost:3036';
$dbuser = 'root';
$dbpass = 'rootpassword';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn ) {
die('Could not connect: ' . mysql_error());
}
$sql = 'INSERT INTO employee '.
'(emp_name,emp_address, emp_salary, join_date) '.
'VALUES ( "guest", "XYZ", 2000, NOW() )';
mysql_select_db('test_db');
$retval = mysql_query( $sql, $conn );
if(! $retval ) {
die('Could not enter data: ' . mysql_error());
}
echo "Entered data successfully\n";
mysql_close($conn);
?>
2. AJAX
AJAX stands for Asynchronous JavaScript and XML. AJAX is a new technique for creating
better, faster, and more interactive web applications with the help of XML, HTML, CSS, and
Java Script.
Ajax uses XHTML for content, CSS for presentation, along with Document Object
Model and JavaScript for dynamic content display.
Conventional web applications transmit information to and from the sever using
synchronous requests. It means you fill out a form, hit submit, and get directed to a
new page with new information from the server.
With AJAX, when you hit submit, JavaScript will make a request to the server,
interpret the results, and update the current screen. In the purest sense, the user would
never know that anything was even transmitted to the server.
XML is commonly used as the format for receiving server data, although any format,
including plain text, can be used.
AJAX is a web browser technology independent of web server software.
A user can continue to use the application while the client program requests
information from the server in the background.
Intuitive and natural user interaction. Clicking is not required, mouse movement is a
sufficient event trigger.
Data-driven as opposed to page-driven.
Conclusion:
Hence, we have studied how to design and develop small web application using PHP,
javascript, ajax, XAMPP server with apache server and MySQL as backend.
Program
1. style.css
body
{
background-image: url("img.jpeg");
background-repeat: no-repeat;
background-size: cover;
}
a
{
margin: 100px 0 0 36px;
}
.login
{
border: 2px solid;
border-radius: 5px;
height: 200px;
margin: 150px 0 auto 400px;
width: 310px;
border-color:#3498DB;
padding-top: 20px;
}
.register
{
border: 2px solid;
border-radius: 5px;
height: 350px;
margin: 150px 0 auto 400px;
width: 310px;
border-color:#3498DB;
padding-top: 20px;
}
input[type="password"], input[type="text"]
{
border:1px solid;
background-color:rgba(0,0,0,0.0);
height: 33px;
width:240px;
margin: 2px 0 0 36px;
padding-left: 10px;
}
input[type="submit"]
{
background-color: #4CAF50;
color: white;
height: 42px;
margin: 10px 0 0 36px;
width: 250px;
padding-left: 10px;
}
input[type="submit"]:hover
{
background-image: linear-gradient(#4ec7c0,#31aba3)
}
input[type="submit"]:active
{
background-image: linear-gradient(#319d91, #3db0a6);
padding: 0;
}
2. index.php
<?php
if($_SERVER['REQUEST_METHOD'] == "POST")
{
$username = $_POST['username'];
$password = $_POST['password'];
$dbusername =NULL;
$dbpassword=NULL;
$db_name = 'tecomp';
$db_user = 'root';
$db_pass = 'root';
$db_host = 'localhost';
if (!$conn )
{
die('Could not connect: ' . mysql_error());
}
else
{
$query = "SELECT * FROM login WHERE username =
'$username' AND password = '$password'";
$retval = mysql_query( $query, $conn );
if(! $retval )
{
die('Could not get data: ' . mysql_error());
}
else
{
while($row = mysql_fetch_array($retval,
MYSQL_ASSOC))
{
$dbusername =$row['username'];
$password=$row['password'];
}
if(!(strcmp($dbusername,$username)or
strcmp($dbusername,$username)) )
{
$_SESSION['id'] = session_id();
header('Location: Home.php');
}
else
{
echo"<center><font color=\"red\">Wrong
UserName Or Password Please Try Again!!</font></center>";
}
}
}
mysql_close($conn);
}
?>
<html>
<head>
<link rel = "stylesheet" type = "text/css" href = "style.css" />
</head>
<body>
<div class="login">
<form action="<?php echo $_SERVER['PHP_SELF'];?>" name="myform"
method="post">
<label><b>Username</b></label>
<input type="text" name="username" id="username" placeholder=
"Username" required="required" onfocus="this.value = '';">
<label><b>Password</b></label>
<input type="password" name="password" id="password"
placeholder="password" required="required" onfocus="this.value =
'';">
<input type="submit" value="Login">
<a href="Register.php"> Register Yourself</a>
</form>
</div>
</body>
</html>
3. Home.php
<html>
<head>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.j
s"></script>
<script type="text/javascript">
function GetCourse()
{
var qual = document.getElementById("qual");
var quali= qual.options[qual.selectedIndex].value;
//alert(quali);
$.ajax({
type: 'GET',
url: "SearchCourse.php",
data: {qualification: quali},
success: function(data)
{
$("p").html(data);
}
});
}
</script>
</head>
<body>
<center>
<h2> <font color="red">Welcome to Course Consultation
Website</h2></font>
</center>
4. SearchCourse.php
<?php
$qual = $_GET['qualification'];
if(strcmp('ssc',$qual)==0)
{
5. Register.php
<?php
if($_SERVER['REQUEST_METHOD'] == "POST")
{
$username = $_POST['username'];
$password = $_POST['password'];
$mobile = $_POST['mobile'];
$email = $_POST['email'];
$age = $_POST['age'];
$db_name = 'tecomp';
$db_user = 'root';
$db_pass = 'root';
$db_host = 'localhost';
if (!$conn )
{
die('Could not connect: ' . mysql_error());
}
else
{
$query = "insert into login
values('$username','$password','$mobile','$email','$age')";
$retval = mysql_query( $query, $conn );
if(! $retval )
{
die('Could not get data: ' . mysql_error());
}
else
{
header('Location: index.php');
}
}
mysql_close($conn);
}
?>
<html>
<head>
<link rel = "stylesheet" type = "text/css" href = "style.css" />
</head>
<body>
<div class="register">
<form action="<?php echo $_SERVER['PHP_SELF'];?>" name="myform"
method="post">
<label><b>Username</b></label>
<input type="text" name="username" id="username"
placeholder= "Username" required="required" onfocus="this.value =
'';">
<label><b>Password</b></label>
<input type="password" name="password" id="password"
placeholder="password" required="required" onfocus="this.value =
'';">
<label><b>Mobile Number</b></label>
<input type="text" name="mobile" id="mobile" placeholder=
"Mobile Number" required="required" onfocus="this.value = '';">
<label><b>E-Mail Address</b></label>
<input type="text" name="email" id="email" placeholder=
"E-Mail Address" required="required" onfocus="this.value = '';">
<label><b>Age</b></label>
<input type="text" name="age" id="age" placeholder= "Age"
required="required" onfocus="this.value = '';">
Output:
1. Login Page
2. Home Page
3. Home Page
4. Registration Page
5. Database
FAQs:
1. What is AJAX?
2. What is jQuery?
3. How many TRIGGERS allows per table in mysql?
4. What is difference between COMMIT and ROLLBACK?
5. What is Ajax?
6. Whether jQuery HTML work for both HTML and XML documents?
7. What is the use of jQuery.ajax method ()?
8. What are Ajax applications?
9. How to control the duration of an Ajax request?
10. What are the advantages and disadvantages of Ajax?
11. Which are the two methods used for cross domain Ajax calls?
12. What are all the technologies used by Ajax?
13. What is JSON in Ajax?
14. What are the difference between AJAX and Javascript?
15. How Ajax objects can be created?
16. What is the use of "echo" in php?
17. How to include a file to a php page?
18. Differences between GET and POST methods ?
19. What is the use of 'print' in php?
20. What is the difference between Session and Cookie?
21. What are the different errors in PHP?
22. How to print current date and time?
23. What is the difference between sql and Mysql?
24. Why do we use GROUP BY and ORDER BY function in mysql?
25. What is JOIN in MySQL? What are the different types of join?
Assignment No: 6
Title: Design and develop any web application using Struts framework.
Objectives:
1. To impart the efficient and available client side and server side technologies.
2. To implement the communication between computing nodes using client side and
server side technologies.
3. To design and implement the web services with content management.
Problem Statement: Re-Design, develop and deploy assignment no. 3 of unit –III using
Strut.
Outcome: Students should be able to,
1. Implement the effective client side and server side technologies using struts
framework.
2. Solve the complex problem of development using MVC framework.
Theory:
Struts 2
1. Introduction
The struts 2 framework is used to develop MVC-based web application. The Struts 2
framework is used to develop MVC (Model View Controller) based web applications. Struts
2 is the combination of webwork framework of opensymphony and struts 1.
Struts 2 provides many features that were not in struts 1. The important features of struts 2
framework are as follows:
1. Configurable MVC components
2. POJO based actions
3. AJAX support
4. Integration support
5. Various Result Types
6. Various Tag support
7. Theme and Template support
2. Components
2.1 web.xml
web.xml file Provide the entry of Controller. In struts
2, StrutsPrepareAndExecuteFilter class works as the controller. As we know well, struts 2
uses filter for the controller. It is implicitly provided by the struts framework.
1. <?xml version="1.0" encoding="UTF-8"?>
2. <web-app>
3. <filter>
4. <filter-name>struts2</filter-name>
5. <filter-class>
6. org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
7. </filter-class>
8. </filter>
9.
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
2.2 struts.xml
It is the important file from where struts framework gets information about the action and
decides which result to be invoked. Here, we have used many elements such as struts,
package, action and result.
struts element is the root elements of this file. It represents an application.
package element is the sub element of struts. It represents a module of the
application. It generally extends the struts-default package where many interceptors
and result types are defined.
action element is the sub element of package. It represents an action to be invoked for
the incoming request. It has name, class and method attributes. If you don't specify
name attribute by default execute() method will be invoked for the specified action
class.
result element is the sub element of action. It represents an view (result) that will be
invoked. Struts framework checks the string returned by the action class, if it returns
success, result page for the action is invoked whose name is success or has no name.
It has name and type attributes. Both are optional. If you don't specify the result
name, by default success is assumed as the result name. If you don't specify the type
attribute, by default dispatcher is considered as the default result type. We will learn
about result types later.
This is simple bean class. In struts 2, action is POJO (Plain Old Java Object). It has one extra
method execute i.e. invoked by struts framework by default.
2.5 StrutsPrepareAndExecuteFilter
Handles both the preparation and execution phases of the Struts dispatching process. This
filter is better to use when you don't have another filter that needs access to action context
information, such as Sitemesh.
StrutsPrepareAndExecuteFilter belongs to org.apache.struts2.dispatcher.ng.filter
package. StrutsPrepareAndExecuteFilter can also be understood by its name.
StrutsPrepareAndExecuteFilter has the responsibility to prepare and execute all phases of
struts. The question is when we shouldz use StrutsPrepareAndExecuteFilter filter. Struts 2
apache documentation says that when there is no other filter being used that can access action
context information, better to use StrutsPrepareAndExecuteFilter filter.
clearErrors() - This method can be used when you want to continue execution, and want to
clear the state of the action.
Conclusion:
Hence, we have studied how to design and develop small web application using Struts, with
apache server and MySQL as backend.
Program
Project Structure:
1. web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID"
version="3.0">
<display-name>Assignment7</display-name>
<welcome-file-list>
<welcome-file>Login.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>Struts2</filter-name>
<filter-
class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilte
r</filter-class>
</filter>
<filter-mapping>
<filter-name>Struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
2. style.css
body
{
background-image: url("img.jpeg");
background-repeat: no-repeat;
background-size: cover;
}
a
{
margin: 100px 0 0 36px;
}
.login
{
3. Login.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Login</title>
<link rel = "stylesheet" type = "text/css" href = "style.css" />
</head>
<body>
<div class="login">
<s:form action="login" method="post">
<s:textfield name="username" label="UName " />
<s:password name="password" label="Password " />
<s:submit label="Login"/>
<s:actionerror/>
</s:form>
<s:a href="Register.jsp">Not Registered? Register Here</s:a>
</div>
</body>
</html>
4. Error.jsp
5. Welcome.jsp
6. Register.jsp
<div class="register">
<s:form action="Register" method="post">
</s:form>
</div>
</body>
</html>
7. struts.xml
<struts>
<package name="Login" namespace="/" extends="struts-default">
<action name="login"
class="nilesh.korade.LoginValidate">
<result name="login">/Welcome.jsp</result>
<result name="error">/Login.jsp</result>
</action>
</package>
</action>
</package>
</struts>
8. DBCon.java
package nilesh.korade;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
return rs;
}
if(id>0)
return true;
else
return false;
}
}
8. LoginValidate.java
package nilesh.korade;
import java.sql.ResultSet;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
public class LoginValidate extends ActionSupport implements Action
{
private static final long serialVersionUID = 1L;
private String username;
private String password;
public String FailMsg = "Please Enter Valid Credentials ...";
if(fl!=1)
{
return ERROR;
}
return LOGIN;
}
9. RegisterUser.java
package nilesh.korade;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.validator.EmailValidator;
import com.opensymphony.xwork2.ActionSupport;
public class RegisterUser extends ActionSupport
{
private String username;
private String password;
private String mobile;
private String email;
private String age;
Output:
1. Login Page
2. Home Page
3. Registration Page
4. Database
FAQs:
Assignment No: 7
Title: Design and develop any web application using AngularJS.
Objectives:
1. Understand the design of single-page applications and how AngularJS facilitates their
development
2. Write AngularJS directives
Problem Statement: Re-Design, develop and deploy assignment no. 4 of unit –IV using
Angular JS.
Outcome: Students should be able to,
1. Develop web based application using suitable client side and server side web
technologies with AngularJS.
Theory:
AngularJS
1. Introduction
AngularJS is an open-source web application framework. It was initially created in 2009 by
MiskoHevery and Adam Abrons. It is presently kept up by Google. Its most recent adaptation
is 1.2.21. "AngularJS is an auxiliary system for dynamic web applications. It gives you a
chance to utilize HTML as your layout dialect and gives you a chance to stretch out HTML's
linguistic structure to express your application parts plainly and compactly. Its information
official and reliance infusion take out a significant part of the code you as of now need to
compose. Also, everything occurs inside the program, making it a perfect band together with
any server innovation".
General Features
AngularJS is a productive system that can make Rich Internet Applications (RIA).
AngularJS gives designers a choices to compose customer side applications utilizing
JavaScript in a spotless Model View Controller (MVC) way.
Applications written in AngularJS are cross-program agreeable. AngularJS
consequently handles JavaScript code reasonable for every program.
AngularJS is open source, totally free, and utilized by a great many engineers the
world over. It is authorized under the Apache permit version2.0.
By and large, AngularJS is a system to assemble expansive scale, elite, and simple
to keep up web applications.
AngularJS is a JavaScript framework. It can be added to an HTML page with a <script> tag.
AngularJS extends HTML attributes with Directives, and binds data to HTML with
Expressions.
<scriptsrc="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angul
ar.min.js"></script>
<div ng-app="">
<p>My first expression: {{ 5 + 5 }}</p>
</div>
</body>
</html>
AngularJS expressions bind AngularJS data to HTML the same way as the ng-binddirective.
<!DOCTYPE html>
<html>
<scriptsrc="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angul
ar.min.js"></script>
<body>
<div ng-app="">
<p>Name: <input type="text" ng-model="name"></p>
<p>{{name}}</p>
</div>
</body>
</html>
2. AngularJS Expressions
Expressions are used to bind application data to html. Expressions are written inside double
braces like {{ expression}}. Expressions behaves in same way as ng-bind directives.
AngularJS application expressions are pure javascript expressions and outputs the data where
they are used.
<!DOCTYPE html>
<html>
<scriptsrc="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angul
ar.min.js"></script>
<body>
<div ng-app="">
<p>My first expression: {{ 5 + 5 }}</p>
</div>
</body>
</html>
If you remove the ng-app directive, HTML will display the expression as it is, without
solving it.
You can write expressions wherever you like, AngularJS will simply resolve the expression
and return the result.
Example: Let AngularJS change the value of CSS properties. Change the color of the input
box below, by changing its value.
<div ng-app="" ng-init="myCol='lightblue'">
<input style="background-color:{{myCol}}" ng-model=
"myCol" value="{{myCol}}">
</div>
3. AngularJS Modules
An AngularJS module defines an application.
The module is a container for the different parts of an application.
The module is a container for the application controllers.
Controllers always belong to a module.
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
});
</script>
</body>
</html>
4. AngularJS Controllers
AngularJS application mainly relies on controllers to control the flow of data in the
application. A controller is defined using ng-controller directive. A controller is a JavaScript
object ontaining attributes/properties and functions. Each controller accepts $scope as a
parameter which refers to the application/module that controller is to control.
<html>
<head>
<title>Angular JS Controller</title>
<script src =
"https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js">
</script>
</head>
<body>
<h2>AngularJS Sample Application</h2>
fullName: function() {
var studentObject;
studentObject = $scope.student;
return studentObject.firstName + " " +
studentObject.lastName;
}
};
});
</script>
</body>
</html>
studentController defined as a JavaScript object with $scope as argument.
$scope refers to application which is to use the studentController object.
$scope.student is property of studentController object.
firstName and lastName are two properties of $scope.student object. We've passed the
default values to them.
fullName is the function of $scope.student object whose task is to return the combined
name.
In fullName function we're getting the student object and then return the combined
name.
As a note, we can also define the controller object in separate JS file and refer that file
in the html page.
We've bounded student.firstName and student.lastname to two input boxes.
We've bounded student.fullName() to HTML.
Now whenever you type anything in first name and last name input boxes, you can
see the full name getting updated automatically.
Conclusion:
Hence, we have studied how to design and develop web application using JSP, Servlet,
AngularJS with apache server and MySQL as backend.
Program
1. style.css
body
{
background-image: url("img.jpeg");
background-repeat: no-repeat;
background-size: cover;
}
a
{
margin: 100px 0 0 36px;
}
.login
{
border: 2px solid;
border-radius: 5px;
height: 200px;
margin: 150px 0 auto 400px;
width: 310px;
border-color:#3498DB;
padding-top: 20px;
}
.register
{
border: 2px solid;
border-radius: 5px;
height: 350px;
margin: 150px 0 auto 400px;
width: 310px;
border-color:#3498DB;
padding-top: 20px;
}
input[type="password"], input[type="text"]
{
border:1px solid;
background-color:rgba(0,0,0,0.0);
height: 33px;
width:240px;
margin: 2px 0 0 36px;
padding-left: 10px;
}
input[type="submit"]
{
background-color: #4CAF50;
color: white;
height: 42px;
margin: 10px 0 0 36px;
width: 250px;
padding-left: 10px;
}
input[type="submit"]:hover
{
background-image: linear-gradient(#4ec7c0,#31aba3)
}
input[type="submit"]:active
{
background-image: linear-gradient(#319d91, #3db0a6);
padding: 0;
}
2. index.php
<?php
if($_SERVER['REQUEST_METHOD'] == "POST")
{
$username = $_POST['username'];
$password = $_POST['password'];
$dbusername =NULL;
$dbpassword=NULL;
$db_name = 'tecomp';
$db_user = 'root';
$db_pass = 'root';
$db_host = 'localhost';
$conn = mysqli_connect($db_host, $db_user, $db_pass,$db_name);
if (!$conn)
{
die('Could not connect: ' . mysqli_error());
}
else
{
$query = "SELECT * FROM login WHERE username =
'$username' AND password = '$password'";
$result = $conn->query($query);
if($result->num_rows < 0)
{
echo"<center><font color=\"red\">Wrong UserName Or
Password Please Try Again!!</font></center>";
}
else
{
$_SESSION['id'] = session_id();
header('Location: Userhome.html');
}
}
$conn->close();
}
?>
<html>
<head>
<link rel = "stylesheet" type = "text/css" href = "style.css" />
</head>
<body>
<div class="login">
<form action="<?php echo $_SERVER['PHP_SELF'];?>" name="myform"
method="post">
<label><b>Username</b></label>
3. Userhome.html
<!DOCTYPE html>
<html>
<style>
table, th , td
{
border: 1px solid grey;
border-collapse: collapse;
padding: 5px;
align: center;
}
table tr:nth-child(odd)
{
background-color: #f1f1f1;
}
table tr:nth-child(even)
{
background-color: #ffffff;
}
</style>
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.m
in.js"></script>
<body>
</div>
</center>
<script>
var app = angular.module('myApp', []);
app.controller('courseCtrl', function($scope, $http)
{
$scope.welcome = "Welcome in Course Counceling Website";
$http.get("course.php")
.then(function (response)
{$scope.names = response.data.records;});
});
</script>
</body>
</html>
4. course.php
{ "records":[
{"qual":"SSC","course":"MSCIT","duration":"3 months"},
{"qual":"SSC","course":"DTP","duration":"3 months"},
{"qual":"HSC","course":"HTML","duration":"1 months"},
{"qual":"HSC","course":"C Programming","duration":"3 months"},
{"qual":"Diploma","course":"OCJP","duration":"3 months"},
{"qual":"Diploma","course":"CCNA","duration":"3 months"},
{"qual":"BE","course":"Software Development","duration":"6 months"},
{"qual":"BE","course":"Software Testing","duration":"6 months"}
] }
5. Register.php
<?php
if($_SERVER['REQUEST_METHOD'] == "POST")
{
$username = $_POST['username'];
$password = $_POST['password'];
$mobile = $_POST['mobile'];
$email = $_POST['email'];
$age = $_POST['age'];
$db_name = 'tecomp';
$db_user = 'root';
$db_pass = 'root';
$db_host = 'localhost';
<body>
<div class="register">
<form action="<?php echo $_SERVER['PHP_SELF'];?>" name="myform"
method="post">
<label><b>Username</b></label>
<input type="text" name="username" id="username"
placeholder= "Username" required="required" onfocus="this.value =
'';">
<label><b>Password</b></label>
<input type="password" name="password" id="password"
placeholder="password" required="required" onfocus="this.value =
'';">
<label><b>Mobile Number</b></label>
<input type="text" name="mobile" id="mobile" placeholder=
"Mobile Number" required="required" onfocus="this.value = '';">
<label><b>E-Mail Address</b></label>
<input type="text" name="email" id="email" placeholder=
"E-Mail Address" required="required" onfocus="this.value = '';">
<label><b>Age</b></label>
<input type="text" name="age" id="age" placeholder= "Age"
required="required" onfocus="this.value = '';">
</form>
</body>
</html>
Output:
1. Login Page
2. Userhome page
3. Registration page
4. Database
FAQs:
1. What is AngularJS and what are some of its advantages?
2. What is the Model View Controller (MVC)?
3. What is data binding in AngularJS? How does it relate to the MVC architecture?
4. Explain the concept of scope. How does scope inheritance work in AngularJS?
5. Explain the difference between a factory and a service in AngularJS?
6. Explain why there are two “destroy” events associated with the termination of a scope in
AngularJS?
7. What is dependency injection and how does it work?
8. What are directives? Can you explain the functions of the following directives?
9. Explain the role of $routeProvider in AngularJS?
Assignment No: 8
Title: Web application using Spring.
Objectives: Understand how to develop a dynamic webpage using Spring Framework,
HTML and JSP.
Problem Statement: Design, Develop and Deploy separate web application using
EJB/CMS/JSF/Spring/Bootstrap..
Outcome: Students will be able to:
1. Understand about basic concepts of Spring, Spring MVC Architecture.
2. How to use Jsp, Servlet inside Spring Framework.
Software & Hardware Requirments:
1. Java 7 or Later
2. Apache Tomcat Server
3. Spring Library
Theory:
1. Introduction:
Spring is a lightweight framework. It can be thought of as a framework of
frameworks because it provides support to various frameworks such as Struts, Hibernate,
Tapestry, EJB, JSF etc. The framework, in broader sense, can be defined as a structure where
we find solution of the various technical problems.
Thus, IOC makes the code loosely coupled. In such case, there is no need to modify the code
if our logic is moved to new environment. In Spring framework, IOC container is responsible
to inject the dependency. We provide metadata to the IOC container either by XML file or
annotation.
1.2 Spring MVC
MVC says we can separate view(UI) and Business Logic(code that generate data by
applying logic).
The Model encapsulates the application data and in general they will consist of POJO.
The View is responsible for rendering the model data and in general it generates
HTML output that the client's browser can interpret.
The Controller is responsible for processing user requests and building appropriate
model and passes it to the view for rendering.
In Java systems, the model is typically a loose JavaBean, or Plain Old Java Object
(POJO) that has getters and setters to manipulate its contents. It can be a very simple object
or a very complicated one with dozens of subobjects, but it's just an object nonetheless.
The view is usually a JSP page, but countless other technologies and templating
languages can be used, such as FreeMarker, Velocity, XML/XSLT, JasperReports, and so on.
After the business logic is complete and the model has been generated, the controller passes
the model to the view to be presented to the user.
The controller is typically implemented by a servlet that calls into business services to
perform some action. The controller usually hosts additional logic such as authentication and
authorization: it controls which actions a user can execute. For example, you might not allow
a user who hasn't first logged in to post a message to a message board. If the controller
notices that the user is trying to access the "post" page, it redirects the user to a login page
first.
data. Then Front controller make contact to View who generate UI for data and pass it to
Front controller and then to client.
<display-name>FirstMVCExample</display-name>
<servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-
class>org.springframework.web.servlet.DispatcherServlet</servlet-
class>
</servlet>
<servlet-mapping>
<servlet-name>spring-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
In this xml file, we are specifying the servlet class DispatcherServlet that acts as the front
controller in Spring Web MVC. All the incoming request for the html file will be forwarded
to the DispatcherServlet.
Consider client make request by using following URL
The DispatcherServlet is Front controller which spring has provided which look
up spring-dispatcher-servlet.xml
The front controller need to determine which controller class need to call with the
help of HandlerMapping class provided by spring MVC framework.
<bean id="HandlerMapping"
class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
This is the important configuration file where we need to specify the ViewResolver
and View components.
Here, the InternalResourceViewResolver class is used for the ViewResolver.
The prefix+string returned by controller+suffix page will be invoked for the view
component. This xml file should be located inside the WEB-INF directory.
BeanNameUrlHandlerMapping:- Handler-Mapping class provided by spring
framework with the help of this class spring framework call to Controller
class(nilesh.korade.HelloController)
Handler-Mapping class matches url pattern with the bean name of the controller class. The
url is /welcome.html and controller is nilesh.korade.HelloController. The it suggest to front
controller to make a call to respected controller.
<bean name="/welcome.html" class="nilesh.korade.HelloController"/>
1.4 Annotation
1.4.1 @Controller: Define Controller
1.4.2 @Request Mapping: Define for which request controller should get executed
1.4.3 @PathVariable: When there is dynamic path mean whose value may change(e.g
/path/country/username). Here username may vary in that case we need to use{}. For
example(/path/country/{username}).
1.4.4 @RequestParam : It is used ti get parameter from form it work same as
“request.getParameter(“name”)” in jsp.
1.4.5 @ModelAttribute:While sending data to jsp we need to create ModelAndView Object,
then we add attribute to ModelAndView Object. But using This annotation we can set
attribute for multiple jsp. The method below @ModelAttribute always get executed before
sending data to particular jsp in Controller class.
Conclusion:
Hence, we have studied how to design and develop small web application using Spring
Framework.
Program:
Project Structure
1. web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID"
version="3.0">
<display-name>StudentRegistration</display-name>
<servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-
class>org.springframework.web.servlet.DispatcherServlet</servlet-
class>
</servlet>
<servlet-mapping>
<servlet-name>spring-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
2. spring-dispatcher-servlet.xml
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewReso
lver">
<property name="prefix">
<value>/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
3. StudentAdmissionController.java
package nilesh.korade;
import java.util.Map;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class StudentAdmissionController
{
@RequestMapping(value="/admissionForm",
method=RequestMethod.GET)
protected ModelAndView myMethod1()
{
ModelAndView mv=new ModelAndView("AdmissionForm");
return mv;
}
@RequestMapping(value="/submitAdmissionForm",
method=RequestMethod.POST)
protected ModelAndView myMethod2(
@RequestParam("studentname") String name,
@RequestParam("password") String password,
@RequestParam("mobile") String mobile,
@RequestParam("email") String email,
@RequestParam("age") String age)
{
ModelAndView mv=new ModelAndView("AdmissionSuccess");
mv.addObject("WelcomeMessage","Details are : <br>Name
:"+name+"<br>Password: "+password+"<br>Mobile No : "
+mobile + "<br>E-Mail : "+email+"<br>Age : "+age);
return mv;
}
}
4. AdmissionForm.jsp
<label><b>Username</b></label>
<input type="text" name="studentname" placeholder= "Username"
required="required" onfocus="this.value = '';">
<br> <label><b>Password</b></label>
<input type="password" name="password" id="password"
placeholder="password" required="required" onfocus="this.value =
'';">
<br><label><b>Mobile Number</b></label>
<input type="text" name="mobile" id="mobile" placeholder= "Mobile
Number" required="required" onfocus="this.value = '';">
<br><label><b>E-Mail Address</b></label>
<input type="text" name="email" id="email" placeholder= "E-Mail
Address" required="required" onfocus="this.value = '';">
<br><label><b>Age</b></label>
<input type="text" name="age" id="age" placeholder= "Age"
required="required" onfocus="this.value = '';">
</form>
</body>
</body>
</html>
5. AdmissionSuccess.jsp
Output:
1. Student Registration
2. Registration Successful
FAQ’s:
1. What is Spring?
2. What are benefits of Spring Framework?
3. Explain the Spring MVC module
4. What is Spring IoC container?
5. What is the difference between Bean Factory and ApplicationContext?
6. What is Dependency Injection in Spring?
7. What are Spring beans?
8. How do you define the scope of a bean?
9. What is Spring Java-Based Configuration? Give some annotation example.
10. What is @Required annotation