adavanced power electronics by ned mohanFull description
Computer Aided Engineering Lab Manual list of Experiments Stress analysis of a plate with a circular hole. Stress analysis of rectangular L bracket Stress analysis of an axi-symmetric component...
Full description
Descripción completa
Full description
Book
Pharma Book written by Mr. Mohan Patidar, Unlocked pdf
Anyone can start learning palmistry through this rich document.It basically mention different mounts and lines of hand.Full description
scdcdsscFull description
erFull description
Full description
ebook having objective type questions on civil engineeringFull description
WEB TECHNOLOGIES LAB MANUAL HTML, Java Script, WAMP SERVER, PHP, APACHE Tomcat Web Server, Servlets, JSP To enable the student to program web applications using following technologies HTML, JavaScript, AJAX, PHP, Tomcat Server, Servlets, JSP.
Prepared by :Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Department
2017-2018
WEB TECHNOLOGIES LAB MANUAL 2017-2018
1) Installation procedure for installing WAMP Server Why WAMP Server? WampServer is a Web development platform on Windows that allows you to create dynamic Web applications with Apache2, PHP, and MySQL. WampServer automatically installs everything you need to intuitively develop Web applications. You will be able to tune your server without even touching its setting files. Best of all, WampServer is available for free in both 32 and 64 bit versions. Step 1:- double click on WampServer2.0i.exe
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 2
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Step 2:- Click on “RUN” button
Step 3:-Click on “Yes” button and then click on “Next” button
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 3
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Step 4:- In License Agreement choose “I accept the agreement” option and click on “Next” button
Step 5:- Select the Destination Location by clicking on the “browse” button and then click on “Next” button
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 4
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Step 6:- If Interested select additional task icons and then click on “Next” button
Step 7:- Click on “Install” button
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 5
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Step 8:-Select “Launch Wamp Server 2 now” option and then Click on “Finish” button
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 6
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Step 9:- After Successful Installation in taskbar wamp server icon will be highlighted then choose it and left click on it and choose “local host”
Step 10:- It will execute a wamp server “index.php” page in browser
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 7
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Step 11:- To stop all services, in taskbar choose wamp server icon and left click on it and choose “Stop All Services”
Step 12:- After selecting “stop all services” in wamp server tray then in taskbar left click on wamp server icon and choose “local host”
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 8
WEB TECHNOLOGIES LAB MANUAL 2017-2018
2) Write an HTML page including any required JavaScript that takes a number from one text field in a range of 0 to 999 and shows it in another text field in words. If the number is out of range, it should show “out of range” and if it is not a number, it should show “not a number” message in result box. convert_number_to_words.html <script type="text/javascript"> var th = ['','thousand','million', 'billion','trillion']; var dg=['zero','one','two','three','four','five','six','seven','eight','nine']; var tn=['ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen', 'seventeen','eighteen','nineteen']; var tw=['twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety'];
function change() { var numString=document.getElementById('anumber').value; var output=towords(numString); document.getElementById('aresult').value=output; }
function towords(s) { s = s.toString(); if (s != parseFloat(s)) Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 9
WEB TECHNOLOGIES LAB MANUAL 2017-2018
return 'not a number'; var x = s.indexOf('.'); /*The indexOf() method returns the position of the first occurrence of a specified value in a string. This method returns -1 if the value to search for never occurs. Note: The indexOf() method is case sensitive. */ if (x == -1) x = s.length; if (x > 3) return 'too big'; var n = s.split(''); /*The split() method is used to split a string into an array of substrings, and returns the new array.
Tip: If an empty string ("") is used as the separator, the string is split between each character.
Note: The split() method does not change the original string.*/ var str = ''; var sk = 0; for (var i=0; i < x; i++) { if ((x-i)%3==2) { if (n[i] == '1') { str += tn[Number(n[i+1])] + ' '; i++; Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 10
WEB TECHNOLOGIES LAB MANUAL 2017-2018
/*The Number() function converts the object argument to a number that represents the object's value.
If the value cannot be converted to a legal number, NaN is returned.
Note: If the parameter is a Date object, the Number() function returns the number of milliseconds since midnight January 1, 1970 UTC.*/ sk=1; } else if (n[i]!=0) { str += tw[n[i]-2] + ' '; sk=1; } } else if (n[i]!=0) { str += dg[n[i]] +' '; if ((x-i)%3==0) str += 'hundred '; sk=1; } if ((x-i)%3==1) { if (sk) Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 12
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Output:- If we given number a 98
If the number is out of range 9999
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 13
WEB TECHNOLOGIES LAB MANUAL 2017-2018
If it is not a number
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 14
WEB TECHNOLOGIES LAB MANUAL 2017-2018
3) Write an HTML page that has one input, which can take multi-line text and a submit button, Once the user clicks the submit button, it should show the number of characters, words and lines in the text entered using an alert message. Words are separated with white space and lines are separated with new line character. finding_no_of_chars_words_lines.html <script type="text/JavaScript"> function count() { var str=document.getElementById('atext').value; var result; result+='The number of characters are '+str.length+'\n'; var arr=str.split(/\b\S+\b/g).length-1; result+='The number of words are '+arr+'\n'; var a=str.split('\n').length; result+='The number of lines are '+a; alert(result); } Output
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 16
WEB TECHNOLOGIES LAB MANUAL 2017-2018
4) Write an HTML page that contains a selection box with a list of 5 countries. When the user selects a country, its capital should be printed next to list. Add CSS to customize the properties of the capital (color, bold and font size). style.css p {font-style: bold; font-size: 26pt;color: blue} finding_captial_city.html Using Select Controls and External CSS <script type="text/javascript">
Page 18
WEB TECHNOLOGIES LAB MANUAL 2017-2018
captial = "Islamabad"; break; case 4: captial = "Beijing"; break; } document.getElementById("demo").innerHTML = "Captial is " + captial;
} //-->
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 19
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Output
After selecting one option “India” the output is
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 20
WEB TECHNOLOGIES LAB MANUAL 2017-2018
5) Create an XML document that contains users information. Write a Java program, which returns the details from the XML document using a) DOM Parser
b) SAX Parser
employees.xml Seagull367434Robin367525Crow367628
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 21
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Employee.java import java.io.*; public class Employee {
private String name;
private int age;
private int id;
private String type;
public Employee(){
}
public Employee(String name, int id, int age,String type) { this.name = name; this.age = age; this.id = id; this.type = type;
} Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 27
WEB TECHNOLOGIES LAB MANUAL 2017-2018
private void parseDocument(){ //get the root elememt Element docEle = dom.getDocumentElement();
//get a nodelist of elements NodeList nl = docEle.getElementsByTagName("Employee"); if(nl != null && nl.getLength() > 0) { for(int i = 0 ; i < nl.getLength();i++) {
//get the employee element Element el = (Element)nl.item(i);
//get the Employee object Employee e = getEmployee(el);
//add it to list myEmpls.add(e); } } }
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 28
WEB TECHNOLOGIES LAB MANUAL 2017-2018
/** * I take an employee element and read the values in, create * an Employee object and return it * @param empEl * @return */ private Employee getEmployee(Element empEl) {
//for each element get text or int values of //name ,id, age and name String name = getTextValue(empEl,"Name"); int id = getIntValue(empEl,"Id"); int age = getIntValue(empEl,"Age");
String type = empEl.getAttribute("type");
//Create a new Employee with the value read from the xml nodes Employee e = new Employee(name,id,age,type);
return e; }
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 29
WEB TECHNOLOGIES LAB MANUAL 2017-2018
/** * I take a xml element and the tag name, look for the tag and get * the text content * i.e for John xml snippet if * the Element points to employee node and tagName is name I will return John * @param ele * @param tagName * @return */ private String getTextValue(Element ele, String tagName) { String textVal = null; NodeList nl = ele.getElementsByTagName(tagName); if(nl != null && nl.getLength() > 0) { Element el = (Element)nl.item(0); textVal = el.getFirstChild().getNodeValue(); }
return textVal; }
/** * Calls getTextValue and returns a int value Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 30
WEB TECHNOLOGIES LAB MANUAL 2017-2018
* @param ele * @param tagName * @return */ private int getIntValue(Element ele, String tagName) { //in production application you would catch the exception return Integer.parseInt(getTextValue(ele,tagName)); }
/** * Iterate through the list and print the * content to console */ private void printData(){
System.out.println("No of Employees '" + myEmpls.size() + "'.");
Iterator it = myEmpls.iterator(); while(it.hasNext()) {
System.out.println(it.next().toString());
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 31
WEB TECHNOLOGIES LAB MANUAL 2017-2018
} }
public static void main(String[] args){ //create an instance DomParserExample dpe = new DomParserExample();
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 37
WEB TECHNOLOGIES LAB MANUAL 2017-2018
6) Implement the following web applications using (a) PHP, (b) Servlets and (c) JSP a) A User Validation web application, where the user submits the login name and password to the server. The name and password are checked against the data already available in database and if the data matches, a successful login page is returned. Otherwise a failure message is shown to the user. In MySQL DB Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.1.36-community-log MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases; +--------------------+ | Database
mysql> show tables; +-------------------+ | Tables_in_logindb | +-------------------+ Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 39
WEB TECHNOLOGIES LAB MANUAL 2017-2018
| login
|
+-------------------+ 1 row in set (0.00 sec)
mysql> desc login; +-------+-------------+------+-----+---------+-------+ | Field | Type
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 46
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Invalid login result
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 47
WEB TECHNOLOGIES LAB MANUAL 2017-2018
c) Modify the above program to AJAX to show the result on same page below the submit button. cd_catalog.xml Empire BurlesqueBob DylanUSAColumbia10.901985Hide your heartBonnie TylerUKCBS Records9.901988Greatest HitsDolly PartonUSA Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 48
WEB TECHNOLOGIES LAB MANUAL 2017-2018
RCA9.901982Still got the bluesGary MooreUKVirgin records10.201990ErosEros RamazzottiEUBMG9.901997
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 49
WEB TECHNOLOGIES LAB MANUAL 2017-2018
tryjs_ajax_xml.html
The XMLHttpRequest Object
<script> function loadDoc() { var xhttp = new XMLHttpRequest(); Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 50
WEB TECHNOLOGIES LAB MANUAL 2017-2018
xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { myFunction(this); } }; xhttp.open("GET", "cd_catalog.xml", true); xhttp.send(); } function myFunction(xml) { var i; var xmlDoc = xml.responseXML; var table="
Artist
Title
"; var x = xmlDoc.getElementsByTagName("CD"); for (i = 0; i
"; } document.getElementById("demo").innerHTML = table; } Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 51
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Input and Output Screen WebPages
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 52
WEB TECHNOLOGIES LAB MANUAL 2017-2018
d) A simple calculator web application that takes two numbers and an operator (+,-,/,* and %) from an HTML page and returns the result page with the operation performed on the operands. calculator.html Simple Calculator calculator.php Simple Calculator
if(isset($_POST['sub'])) { $txt1=$_POST['n1']; $txt2=$_POST['n2'];
$oprnd=$_POST['sub'];
if($oprnd=="+") $res=$txt1+$txt2; else if($oprnd=="-") Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 55
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Input Screen
Output Screen
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 56
WEB TECHNOLOGIES LAB MANUAL 2017-2018
e) Modify the above program such that it stores each query in a database and checks the database first for the result. If the query is already available in DB, it returns the value that was previously computed (from DB) or it computes the result and returns it after storing the new query and result in DB. Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.1.36-community-log MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases; +--------------------+ | Database
$result=mysql_query($query) or die("Duplicate entry '$empid':Already Registered");
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 60
WEB TECHNOLOGIES LAB MANUAL 2017-2018
$query="SELECT * FROM register WHERE empid='$empid'";
$result=mysql_query($query) or die("query failed:".mysql_error());
echo "
successfully Registered
"; echo "
"; echo "
"; echo "
empid
empname
"; echo "
";
while($row=mysql_fetch_array($result)) { echo "
"; echo "
",$row['empid'],"
",$row['empname'],"
"; echo "
"; } echo "
";
mysql_close($connection); ?> Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 61
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Input and Output Screen web Pages
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 62
WEB TECHNOLOGIES LAB MANUAL 2017-2018
f)
A web application takes a name as input and on submit it shows a hello page where is taken from the request. It shows the start time at the right top corner of the page and provides logout button. On this button, it should show a logout page with Thank you message with the duration of usage (hint: Use Session to store name and time).
phpinput.html Session to store name and time
Session to store name and time
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 63
WEB TECHNOLOGIES LAB MANUAL 2017-2018
phpsession.php Session to store name and time welcome to".$_REQUEST['data']; echo " "; echo "logout"; ?> phpsession2.php Session to store name and time
Page 64
WEB TECHNOLOGIES LAB MANUAL 2017-2018
session_start();
if(isset($_SESSION['name']) and isset( $_SESSION['time'])){ echo ""; echo "Thank you ".$_SESSION['name']; echo " and your Session Duration is"; echo " "; echo (time()-$_SESSION['time']); echo " Seconds"; } ?> Input and Output Screen Web Pages
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 65
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 66
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Installation of Apache Tomcat Web Server Why Apache Tomcat? Apache Tomcat is used to deploy your Java Servlets and JSPs. So in your Java project you can build your WAR (short for Web ARchive) file, and just drop it in the deploy directory in Tomcat. So basically Apache is an HTTP Server, serving HTTP. Tomcat is a Servlet and JSP Server serving Java technologies. Step 1:- double click on apache-tomcat-6.0.48.exe
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 67
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Step 2:- click on “yes” and next click on “next”
Step 3:- click on “I Agree” button at License Agreement
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 68
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Step 4:- Choose all components and click on “next”
Step 5:- Configure or change default http port to other than 8080 to avoid conflict with servers on our system (8081) and assign any Username and Password to manage web applications on server (Username – tomcat, Password-tomcat) and click on “next”
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 69
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Step 6:- Java virtual machine path selection is done automatically if java jdk1.5 or later already installed on our computer machine if not install java jdk. Click on “next”
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 70
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Step 7:-choose the tomcat install location on our system and click on “Install”
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 71
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Step 8:-finally click on “finish”
Step 9:- It is “Running Apache Tomcat”
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 72
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Step 10:- If it is running the icon look below
Apache Tomcat is in running mode (green play button)
Step 11:- if it is in running mode we can manage web application using apache tomcat by typing URL in browser as http://localhost:8081 and click on “manage apps” or “Tomcat manager” and enter username and password as “tomcat” and click on “ok” button
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 73
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 74
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Step 12:- To stop tomcat server left click on apache tomcat icon in task bar and click on “Stop Service”
Step 13:- typing URL in browser as http://localhost:8081 it show the result as below
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 75
WEB TECHNOLOGIES LAB MANUAL 2017-2018
g) A web application that takes name and age from an HTML page. If the age is less than 18, it should send a page with “Hello , you are not authorized to visit this site” message, where should be replaced with the entered name. Otherwise it should send “Welcome to this site” message. Step 1:- Create a project directory “my_project” and save “index.html” in “D:\my_project\index.html” First Servlet Step 2:- Create a “WEB-INF” directory in “D:\my_project” and create a “classes” directory in “D:\my_project\WEB-INF” and create and save “FirstServlet.java” program in “D:\my_project\WEBINF\classes” import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class FirstServlet extends HttpServlet { Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 76
WEB TECHNOLOGIES LAB MANUAL 2017-2018
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
String name=request.getParameter("name"); int age=Integer.parseInt(request.getParameter("age"));
Hello"); out.println(name); out.println(" you are not authorized to visit this site
"); }else{ out.println("
Welcome"); out.println(name); Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 77
WEB TECHNOLOGIES LAB MANUAL 2017-2018
out.println(" to this site
"); } out.println(""); out.println(""); } public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { doPost(request,response); } } Step 3:- Create “web.xml” deployment descriptor and it in “D:\my_project\WEB-INF” First Servlet Example.index.htmlServletFirstServlet Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 78
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Servlet/cse Step 4:-Before compiling servlet programs on a computer machine assign the environment variables path=C:\Program Files\Java\jdk1.8.0_144\bin;.; classpath= C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar;.; Step 5:-open command prompt window and compile java program as D:\my_project\WEB-INF\classes >javac FirstServlet.java Step 6:-create war file “my_project.war” using following command D:\my_project>jar –cvf my_project.war *
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 79
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Step 7:-Switch on Apache Tomcat server – choose “configure Tomcat”, click on “Start”, and click on “Ok” button
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 80
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 81
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Step 8:-Open any browser and type URL as http://localhost:8081 and click on “manage apps” or “Tomcat manager” and enter username and password as “tomcat” and click on “ok” button
Step 9:- Choose – WAR file to deploy by uploading “D:\my_project\my_project.war” and click on “Deploy” button.
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 82
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Step 10:- After perfect deploy click on “/my_project” link path in Applications
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 83
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Input and Output Screens of Webpage
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 84
WEB TECHNOLOGIES LAB MANUAL 2017-2018
h) A web application for implementation: The user is first served a login page which takes User’s name and password. After submitting the details the server checks these values against the data from a database and takes the following decisions. If name and password matches, serves a welcome page with user’s full name If name matches and password doesn’t match, then serves “password mismatch” page If name is not found in database, serves a registration page, where user’s full name is asked and on submitting the full name, it stores, the login name, password and full name in database @My SQL Database Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 35 Server version: 5.1.36-community-log MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use userdb; Database changed mysql> desc user; +----------+-------------+------+-----+---------+-------+ | Field | Type
| Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+ | userid | varchar(20) | NO | PRI | NULL | | password | varchar(20) | NO |
| NULL |
| |
+----------+-------------+------+-----+---------+-------+ Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 85
WEB TECHNOLOGIES LAB MANUAL 2017-2018
2 rows in set (0.05 sec)
mysql> select * from user; +------------+----------+ | userid
| password |
+------------+----------+ | murali
| vgse
|
| mmr
| vec
|
| mcubereddy | vce | madhu
| mca
| |
| rahul
| vgse
|
| sachin
| sachin |
| dhoni
| dhoni |
+------------+----------+ 7 rows in set (0.00 sec)
mysql> index.html Servlet using JDBC with MySQL Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 92
WEB TECHNOLOGIES LAB MANUAL 2017-2018
web.xml Servlet using JDBC with MySQLindex.htmlServletDBServletServlet/loginServlet1DBServlet1Servlet1/register Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 93
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Input and Output Screen WebPages Input existing user id and pwd (murali, vgse)
Input existing user id but wrong pwd (murali, vcp)
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 94
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Input not existed user id and pwd (cse,cse)
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 95
WEB TECHNOLOGIES LAB MANUAL 2017-2018
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 96
WEB TECHNOLOGIES LAB MANUAL 2017-2018
i)
A web application that lists all cookies stored in the browser on clicking “List Cookies” button. Add cookies if necessary. hello.jsp
main.jsp <% // Create cookies for first and last names. Cookie firstName = new Cookie("first_name", request.getParameter("first_name")); Cookie lastName = new Cookie("last_name", request.getParameter("last_name"));
// Set expiry date after 24 Hrs for both the cookies. firstName.setMaxAge(60*60*24); lastName.setMaxAge(60*60*24); Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 97
WEB TECHNOLOGIES LAB MANUAL 2017-2018
// Add both the cookies in the response header. response.addCookie( firstName ); response.addCookie( lastName ); %>
Setting Cookies
Setting Cookies
First Name: <%= request.getParameter("first_name")%>
Last Name: <%= request.getParameter("last_name")%>
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE
Page 98
WEB TECHNOLOGIES LAB MANUAL 2017-2018
main1.jsp Reading Cookies
Reading Cookies
<% Cookie cookie = null; Cookie[] cookies = null;
// Get an array of Cookies associated with the this domain cookies = request.getCookies();
if( cookies != null ) { out.println("
Found Cookies Name and Value
");
Prepared By Mr. M. Murali Mohan Reddy, Assistant Professor, CSE Dept, VCE