Cs8661 Ip Rec
Cs8661 Ip Rec
Cs8661 Ip Rec
AIM:
To create a web page which includes a map and display the related information when a
hotspot is clicked in a map.
ALGORITHM:
1. Start the program for embed map in web page
2. Create world.html file using notepad
3. The <map> tag is used to define a client-side image-map.
4. An image-map is an image with clickable areas.
5. The name attribute is required in the map element. This attribute is associated with the
<img> usemap attribute and creates a relationship between the image and the map.
6. The map element contains a number of area elements that defines the clickable areas in the
image map.
7. Set the coordination for the Hotspot areas
8. Finally terminate the program and embed web page.
AFRICA.HTML:
<head>
<title>AFRICA</title>
<h1 align=center>Africa includes 53 Individual Countries</h1>
<br>
<p>
<img align="left" src="C:\Documents and Settings\Owner\Desktop\wt lab manual 2010\pgm
1\imagesCA1BWOB7.jpg" height=320 width=320></img></p>
</br>
<table border=5>
<tr>
<th align=left>Continent Size:</th>
<td align=left>11,700,000 square miles</td>
</tr>
<tr>
<th align=left>Estimated Population:</th>
<td align=left>877 million people</td>
</tr>
<tr>
<th align=left>Largest Country:</th>
<td align=left>Sudan, 968,000 square miles</td>
</tr>
<tr>
<th align=left>Longest River:</th>
<td align=left>Nile, 4,160 miles </td>
</tr>
</table>
AUSTRALIA.HTML:
<head>
<title>Australia</title>
<h1 align=center>Austalia is the 6th largest country and the smallest continent.</h1>
<br>
<p>
<img align="left" src="C:\Documents and Settings\Owner\Desktop\wt lab manual 2010\pgm
1\australia.jpg" height=320 width=320></img></p>
</br>
<table border=5>
<tr>
<th align=left>Continent Size:</th>
<td align=left>7,682,300 square km</td>
</tr>
<tr>
<th align=left>Estimated Population:</th>
<td align=left>21 million people</td>
</tr>
<tr>
<th align=left>land masses:</th>
<td align=left>mainland and Tasmania</td>
</tr>
<tr>
<th align=left>Largest Desert:</th>
<td align=left>The Great Victoria Desert</td>
</tr>
</table>
</body>
Thus the program for image mapping is successfully executed and output is verified.
AIM:
To create a web page with the following Cascading style sheets (CSS)
Inline style
Embedded style
External style
ALGORITHM:
1. Start by three ways of employing CSS in your Web pages :inline styles, embedded or
global styles, and linked or external style sheets.
2. To create an inline style
a. Add the style attribute to the HTML tag.
b. The style declaration must be enclosed within double quotation marks.
3. To create an embedded style
a. Insert a <style> tag within the head section of HTML file.
b. Within the <style> tag, enclose the style declarations need to the entire Web page.
c. The style sheet language identifies the type of style used in the document.
d. The default and the most common language is “text/css” for use with CSS.
4. To create an External styles
a. Create a text file containing style declarations
b. Create a link to that file in each page of the Web site using a <link> tag.
c. Specify the link attributes, such as href, rel, and type.
d. Link a style sheet, the value of the href attribute should be the “URL” of the linked
document, the value of the rel attribute should be “stylesheet” and the value of the type
attribute should be “text/css”.
5. Write the source code for the separate style sheet and finally terminate the program.
HOME.HTML:
<html>
<head>
<title>CASCADING STYLE SHEET</title>
</head>
<body alink="blue" vlink="brown">
<h1><u><b><font face="Monotype corsiva" color="red">
Different types of Cascading Style Sheets</font></b></u></h1>
</ a href="inline.html" style="text-decoration:none:">1.INLINE STYLE SHEET</a></br>
<a href="embed.html" style="text-decoration:none:">1.EMBEDED STYLE SHEET</a></br>
<a href="external.html" style="text-decoration:none:">1.EXTERNAL STYLE
SHEET</a></br><fontface="arial" size="6">
</body>
</html>
INLINE.HTML:
<html>
<head>
<title>INLINE STYLE SHEET</title>
</head>
<body>
<ol class="decimal">
<h1 style="font-family":Times New Roman,sans-serif;font-size;20pt;
color:green"><li>Inline Style Sheet</li></h1>
<h3>
EMBED.HTML:
<html>
<head>
<title>EMBEDDED STYLE SHEET</title>
<style type="text/css">
ol.a{list-style-type:lower-roman}
h1{
font-family:arial black;
font-size:30pt;
color:orange;
text-align:center;}
h3{
font-family:arial black;
font-size:16pt;
color:blue;
text=align:left;}
</style>
</head>
<body>
<ol class="a">
<h1>
<li>Embedded style sheet</li></h1>
EXTERNAL.HTML:
<html>
<head>
<title>IMPORTED STYLE SHEET</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<h1>External Style Sheet</h1>
<h3>An External style sheet is ideal when the style is applied to many pages.with an external
style sheet,Each page must link to the style sheet using the<link>tag.</h3>
</body>
</html>
STYLE1.CSS:
body{background-color:#EEEEFF;colr:black;}
h1{font-family:arial black;font-size:25pt;color:orange;text-align:center;}
h3{text-indent:30pt;font -family:arial black;font-size:12pt; color:blue;text-align:left;}
DATE:
AIM:
Validate the Registration, user login, user profile and payment by credit card pages using
JavaScript.
ALGORITHM:
1. Start the program
2. Create Registration.html file using notepad
3.Insert the data into the user login account.
4. An User profile can be updated by java script.
5. The name attribute is required in the payment element. This attribute is associated with the
Credir card attribute and creates a relationship between the user profile and payment.
PROGRAM:
Home page:
Main.html:
<frameset cols=”25%,75%”>
</frameset>
</frameset>
Top.html:
<html>
<br><br>
STORAGE</u></b></h1></marquee>
</body>
</html>
Right.html:
<html>
<body bgcolor=”pink”>
<br><br><br><br><br>
<h2 align=”center”>
<b><p> welcome to online book storage. Press login if you are having id otherwise press
registration.
</p></b></h2>
</body></html>
Left.html:
<html>
<body bgcolor=”pink”>
<h3>
<ul>
<br>
<br>
</li><br><br>
</ul>
</body>
</html>
Login.html:
<html>
<body bgcolor="pink"><br><br><br>
<script language="javascript">
function validate()
var flag=1;
if(document.myform.id.value==""||
document.myform.pwd.value=="")
flag=0;
if(flag==1)
alert("VALID INPUT");
else
alert("INVALID INPUT");
document.myform.focus();
</script>
<form name="myform">
<div align="center"><pre>
</pre><br><br>
</div>
<br><br>
<div align="center">
</form>
</body>
</html>
Profile.html:
<body bgcolor=”pink”><br><br>
<script language=”javascript”>
function validate()
var flag=1;
if(document.myform.name.value==””||
document.myform.addr.value==””||
document.myform.phno.value==””||
document.myform.id.value==””||
document.myform.pwd.value==””)
flag=0;
var str=document.myform.phno.value;
var x;
for(var i=0;i<str.length;i++)
x=str.substr(i,1)
if(!(x<=9))
flag=0;
break;
alert("VALID INPUT");
else
alert("INVALID INPUT");
document.myform.focus();
}}
</script>
<form name="myform">
<div align="center"><pre>
<br> 19
</div>
<br><br>
<div align="center">
</form></body></html>
Books catalog :
Scart.html:
<body bgcolor="pink"><br><br><br>
<script language="javascript">
function validate()
var flag=1;
if(document.myform.title.value=="")
flag=0;
str=document.myform.title.value;
if(str=="c")
document.writeln("<body bgcolor=pink>");
document.writeln("title-->c"+" cost-->444");
else if(str=="jsp")
document.writeln("<body bgcolor=pink>");
document.writeln("title-->jsp"+" cost-->555");
else
flag=0;
alert("VALID INPUT");
else
alert("INVALID INPUT");
document.myform.focus();
</script>
<div align="center"><pre>
</pre><br><br>
</div>
<br><br>
<div align="center">
</form>
</body>
</html>
Catalog.html:
<html>
<body bgcolor="pink"><br><br><br>
<script language="javascript">
function validate()
var flag=1;
if(document.myform.id.value==""||
document.myform.title.value==""||
document.myform.no.value==""||
document.myform.cost.value==""||
document.myform.date.value=="")
flag=0;
var str=document.myform.no.value;
var x;
for(var i=0;i<str.length;i++)
x=str.substr(i,1)
if(!(x<=9))
flag=0;
str=document.myform.title.value;
var str1=document.myform.cost.value;
flag=0;
if(flag==1)
alert("VALID INPUT");
else
alert("INVALID INPUT");
document.myform.focus();
</script>
<div align="center"><pre>
BOOKS
COST OF BOOK
:<input type="text"name="cost"><br>
</div>
<br><br>
<div align="center">
</form>
</body>
</html>
Payment.html:
<html>
<body bgcolor="pink"><br><br><br>
<script language="javascript">
function validate()
var flag=1;
if(document.myform.id.value==""||
document.myform.pwd.value==""||
document.myform.amount.value==""||
document.myform.num.value=="")
var str=document.myform.amount.value;
var x;
for(var i=0;i<str.length;i++)
x=str.substr(i,1);
if(!(x<=9))
flag=0;
break;
str=document.myform.num.value;
for(var i=0;i<str.lenght;i++)
x=str.substr(i,1);
if(!(x<=9))
flag=0;
break;
if(flag==1)
else
alert("INVALID INPUT");
document.myform.focus();
</script>
<form name="myform">
<div align="center"><pre>
type="PASSWORD"
name="num+"><br></pre><br><br>
</div>
<br><br>
<div align="center">
</form>
</body>
</html>
Order Conformation
<html>
<head><title>order conformation</title><M/head>
<body bgcolor="cyan">
<center>
<h1><b>AMAZON</h1>
<pre><strong>
</strong></pre>
<h2><b>THANK YOU</h2>
</center>
</body>
</html>
OUTPUT:
RESULT:
Thus the resitration form with all types of checking process is successfully executed.
AIM:
ALGORITHM:
PROGRAM :
<HTML>
<head>
<TITLE>INVOKING SERVLET FROM HTML</TITLE>
</head>
<BODY>
<CENTER>
SERVLET CODE:
import java.io.*;
import java.util.*;
}
}
OUTPUT:
AIM:
ALGORITHM:
Step 4: Use doGet() method to get request parameter and also implement necessary exception
handling mechanism.
newhtml.html
<html>
<head>
<title></title>
</head>
<body>
<form action="servlet1">
</form>
</body>
</html>
FirstServlet.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
try{
response.setContentType("text/html");
String n=request.getParameter("userName");
out.print("Welcome "+n);
out.print("</form>");
out.close();
}catch(Exception e){System.out.println(e);}
SecondServlet.java
import java.io.*;
import javax.servlet.ServletException;
import javax.servlet.http.*;
try{
response.setContentType("text/html");
String n=request.getParameter("uname");
out.print("Hello "+n);
catch(Exception e)
System.out.println(e);}
OUTPUT:
AIM:
To write servlet program to conduct online examination and to update mark in a database.
ALGORITHM:
PROGRAM:
SERVLET CODE:
<%@ page language="java" import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%
String SeatNum,Name;
String ans1,ans2,ans3,ans4,ans5;
int a1,a2,a3,a4,a5;
a1=a2=a3=a4=a5=0;
Connection connect=null;
<br/>
<b>5. HTTP is a statefull protocol</b><br/>
<input type="radio" name="group5" value="True">True
<input type="radio" name="group5" value="False">False<br>
<hr/>
<center>
<input type = "submit" value="Submit">
<input type = "reset" value="Clear"><br><br>
</center>
</form>
<%}%>
Thus the java servlet programs to conduct online examination and to display student mark list
available in a database was successfully executed and verified.
AIM :
To Install & Configure TOMCAT web server.
PROCEDURE:
1. Visit Apache Tomcat home page with a Web browser, and click the "Download" link under
the "Tomcat 7.0.70 Released" section. You will see the "Tomcat 7 Downloads" page.
2. Click "32-bit Windows zip" link under "Binary Distributions" section. You will see the
download file save dialog box.(this supports jdk1.6 kit)
3. Use the "Save file" option to save the download file "apache-tomcat-7.0.70-windows-x86.zip"
to a temporary folder.
4. Unzip "apache-tomcat-7.0.70-windows-x86.zip" to file installation folder “C:\ apache-tomcat-
7.0.70”
5. Try to start Tomcat server by running the "startup" command in a command line window:
C:\ >cd apache-tomcat-7.0.70\bin
C:\ >cd apache-tomcat-7.0.70\bin>startup
The CATALINA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
6. To fix the missing environment variables, CATALINA_HOME,JAVA_HOME &
JRE_HOME,
Click my computer->right click properties->Select Advance System Setting
In this tab, Click Environment variable
Click new in User variables for admin
Enter variable name & Variable value
CATALINA_HOME C:\apache-tomcat-7.0.70
JAVA_HOME C:\Program Files\Java\
JRE_HOME C:\Program Files\Java\jre7
AIM :
To create a servlet program & run it on tomcat server
PROCEDURE:
Steps to create the servlet using Tomcat server
1. Create a directory structure
C:\apache-tomcat-7.0.70\\webapps
Create folder HELLO
Create folder WEB-INF
Create folder classes
2. Create a Servlet program using notepad(hw.java)
3. Save hw.java in D:\java\jdk1.6.0\bin
4. Compile servlet using following command
D:\Java\jdk1.6.0\bin>javac -classpath C:\apache-tomcat-7.0.70\lib\servlet-api.jar
hw.java
D:\Java\jdk1.6.0\bin>
5. Copy the hw.class file
6. Paste it into “C:\apache-tomcat-7.0.70\\webapps\HELLO\WEB-INF\classes”
folder
7. Copy web.xml file from “C:\apache-tomcat-7.0.70\webapps\ROOT\WEB-INF”
and paste it into “C:\apache-tomcat-7.0.70\\webapps\HELLO\WEB-INF”
8. Open web.xml in your project HELLO and type the deployment descriptor coding
9. Start the Tomcat server (startup)
10. Open the browser and access the file http://localhost:8080/HELLO/hw
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
OUTPUT:
RESULT:
Thus, the servlet program has been executed in tomcat webserver
AIM:
To create a online shopping cart & maintain session information using cookies using jsp.
PROCEDURE:
1. Create a webpage to show the products information and design a form to collect the
details
2. Invoke jsp program to display the cart details of the user
3. Use cookies to identify whether the user is a new user or existing user
4. If the user has already visited the site ,then display his old order details also.
SAMPLE PROGRAM:
cart.html
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<frameset rows="15%,75%">
<frame name="f1" src="head.html">
<frameset cols="15%,75%">
<frame name="f2" src="links.html">
<frame name="f3" >
</frameset>
</frameset>
</body>
</html>
</body>
</html>
log.html
<html>
<body>
<center>WELCOME TO OUR SITE</center><br>
<form name="form1" action="http://localhost:9816/WebApplication1/order"
mathod="GET">
Name<input type="text" name="t1"><br><br>
Select Item in the List<br><br>
<select name="products" >
<option value="0">None</option>
order.java
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Cookie;
public class order extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)throws
ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String uname=request.getParameter("t1");
String item=request.getParameter("products");
String op=new String();
AIM:
Redo the previous task using JSP by converting the static web pages of assignments 2
into dynamic web pages. Create a database with user information and books information and
books information. The books catalogue should be dynamically loaded from the database.
Follow the MVC architecture while doing the website.
PROCEDURE:
Catalina.bat run
At install-dir/bin
Home page:
Main.html:
<html>
<body>
<br><br><br><br><br><br>
<h2 align="center"><PRE>
</b></PRE></h2>
<br><br><pre>
<a href="reg.html">REGISTRATION</a></div></pre>
</body></html>
Login page:
Login.html:
<html>
<div align="center"><pre>
</div>
<div align="center">
</div>
</form>
</body>
Registration page:
Reg.html:
<html>
<tr>
<td>NAME</td>
</tr>
<tr>
<td>ADDRESS</td>
</tr>
<tr>
<td>CONTACT NUMBER</td>
</tr>
<tr>
<td>LOGINID</td>
</tr>
<tr>
<td>PASSWORD</td>
</tr>
</table>
<div align="center">
</div>
</form>
</body>
</html>
Profile.html:
<html>
<div align="center"><pre>
</div>
<div align="center">
</div>
</body>
</html>
Catalog.html:
<html>
<div align="center"><pre>
</div>
<div align="center">
name="button1"/>
</div>
</form>
</body> </html>
Conformation page:
Order.html:
<html>
<div align="center"><pre>
ID
PASSWORD
:<input type="text" name="title" /><br /> NO. OF BOOKS :<input type="text" name="no"
/><br />
DATE
</div>
<div align="center">
name="button2"/>
</div>
</form>
</body>
</html>
Login JSP:
Login.jsp:
<%@page import="java.sql.*"%>
<% out.println("<html><body>");
String id=request.getParameter("id");
String pwd=request.getParameter("pwd");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection
con=DriverManager.getConnection("jdbc:odbc:orcl","scott","tiger"); Statement
stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(sqlstmt);
int flag=0;
while(rs.next())
if(id.equals(rs.getString(1))&&pwd.equals(rs.getString(2)))
flag=1;
if(flag==0)
ID<br><br>");
RETRY</a>");
out.println("<li><a
href=\"profile.html\"><fontcolor=\"black\">USER
PROFILE</font>
</a></li><br><br>");
out.println("<li><a
href=\"catalog.html\"><fontcolor=\"black\">BOOKS
CATALOG</font></a></li><br><br>");
out.println("<li><a
href=\"order.html\"><fontcolor=\"black\">ORDER
CONFIRMATION</font>
</a></li></ul><br><br>");
out.println("</body></html>");
con.close();
%>
Registration JSP:
Reg.jsp :
<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
<% response.setContentType("text/html");
out.println("<html><body>");
String name=request.getParameter("name");
String phno=request.getParameter("phno");
String id1=request.getParameter("id");
String pwd1=request.getParameter("pwd");
int no=Integer.parseInt(phno);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection
con=DriverManager.getConnection("jdbc:odbc:orcl","scott","tiger"); Statement
stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(sqlstmt);
int flag=0;
while(rs.next())
{ if(id1.equals(rs.getString(1))&&pwd1.equals(rs.getString(2)))
flag=1;
if(flag==1)
RETRY</a>");
else
values('"+name+"','"+addr+"',"+no+",'"+id1+"','"+pwd1+"');"); out.println("<br><br>YOUR
DETAILS
ARE
ENTERED<br><br>");
login</a>");
out.println("</body></html>");
con.close();
%>
Profile JSP:
Profile.jsp:
<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
<% out.println("<html><body>");
String id=request.getParameter("id");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection
con=DriverManager.getConnection("jdbc:odbc:orcl","scott","tiger"); Statement
stmt=con.createStatement();
int flag=0;
out.println("<br><br><br>");
out.println("<div align=\"center\">");
out.println("NAME :"+rs.getString(1)+"<br>");
out.println("ADDRESS
:"+rs.getString(2)+"<br>");
out.println("PHONE NO
:"+rs.getString(3)+"<br>");
out.println("</div>");
flag=1;
if(flag==0)
ID<br><br>");
RETRY</a>");
out.println("</body></html>");
con.close(); %>
Catalog JSP:
Catalog.jsp:
<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
<% out.println("<html><body>");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection
con=DriverManager.getConnection("jdbc:odbc:orcl","scott","tiger"); Statement
stmt=con.createStatement();
int flag=0;
while(rs.next())
out.println("<div align=\"center\">");
out.println("TITLE
:"+rs.getString(1)+"<br>");
:"+rs.getString(5)+"<br>");
out.println("</div>");
flag=1;
if(flag==0)
AGAIN <br><br>");
RETRY</a>");
out.println("</body></html>");
con.close();
%>
Order servlet:
Order.java:
<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
out.println("<html><body>");
String id=request.getParameter("id");
String pwd=request.getParameter("pwd");
String title=request.getParameter("title");
String count1=request.getParameter("no");
String date=request.getParameter("date");
String cno=request.getParameter("cno");
count=Integer.parseInt(count1);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection
con=DriverManager.getConnection("jdbc:odbc:orcl","scott","tiger"); Statement
stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(sqlstmt);
int flag=0,amount,x;
if(id.equals(rs.getString(1))&&pwd.equals(rs.getString(2)))
flag=1;
if(flag==0)
ID<br><br>");
else
Statement stmt2=con.createStatement();
int flag1=0;
while(rs1.next())
flag1=1;
x=Integer.parseInt(rs1.getString(1));
amount=count*x;
out.println("<br><br>AMOUNT
:"+amount+"<br><br><br><br>");
if(flag1==0)
out.println("<br><br><br>SORRY INVALID ID
RETRY</a>");
out.println("</body></html>");
con.close();
%>
OUTPUT:
AIM:
To write a program that accepts user id as input and displays the user details by retrieving the
user information from the XML document.
ALGORITHM:
PROGRAM:
USER INFORMATION
<?xml version="1.0"?>
<userdata>
<user1>
<jntuno>561</jntuno>
<name> chandu</name>
<phno>9989891510</phno>
<address>srikakulam</address>
<user2>
<jntuno>540</jntuno>
<name> karteek</name>
<phno>9701443556</phno>
<address>srikakulam1</address>
</user2>
<user3>
<jntuno>525</jntuno>
<name> giri</name>
<phno>9897895301</phno>
<address>rajam</address>
</user3>
<user4>
<jntuno>526</jntuno>
<name>gopi</name>
<phno>9999789540</phno>
<address>parlakimidi</address>
</user4>
<user5>
<jntuno>513</jntuno>
<phno>9989233331</phno>
<address>hyderabad</address>
</user5>
<user6>
<jntuno>514</jntuno>
<name> balaji</name>
<phno>9999789560</phno>
<address>vizag</address>
</user6>
<user7>
<jntuno>567</jntuno>
<name>kiran </name>
<phno>9999178957</phno>
<address>vijayanagaram</address>
</user7>
<user8>
<jntuno>518</jntuno>
<name> sekhar</name>
<phno>789580</phno>
<address>bobili</address>
<user9>
<jntuno>517</jntuno>
<name>chaitu</name>
<phno>789590</phno>
<address>sallur</address>
</user9>
<user10>
<jntuno>595</jntuno>
<name> sravan</name>
<phno>9000789500</phno>
<address>sklm</address>
</user10>
</userdata>
INFORMATION RETRIVAL
<html>
<head>
</head>
<body>
xmldoc.load("data.xml");
var ele=xmldoc.documentElement;
var node=ele.childNodes.item(y-1);
for(var i=0;i<node.childNodes.length;i++)
var child=node.childNodes.item(i);
var val=child.firstChild;
document.write("<h2>"+child.nodeName+":"+val.nodeValue);
</script>
</body>
</html>
RESULT:
Thus the program to create XML file for retrieving user information has been successfully
executed and the output was verified.
PROGRAM:
Form.html
<form action="http://foo.com/foo.php" method="get"> <div> City: <input name="city" /> <br />
State: <input name="state" size="2" maxlength="2" /> <br /> ZIP: <input name="zip" size="5"
maxlength="5" /> <br /> <input type="submit" /> </div></form>
$state = $_REQUEST["state"];
if (!preg_match("/[A-Z]{2}/", $state)) {
?>
<h2>Error, invalid state submitted.
</h2>
<?php
}
OUTPUT:
RESULT:
Thus the program to validate the form using php has been successfully executed and the output
was verified.
AIM:
ALGORITHM:
PROGRAM:
<html>
<head>
<style>
.error {color: #FF0000;}
</style>
</head>
<body>
<?php
// define variables and set to empty values
$nameErr = $emailErr = $genderErr = $websiteErr = "";
$name = $email = $gender = $comment = $website = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"])) {
$nameErr = "Name is required";
}else {
$name = test_input($_POST["name"]);
if (empty($_POST["email"])) {
$emailErr = "Email is required";
}else {
$email = test_input($_POST["email"]);
if (empty($_POST["website"])) {
$website = "";
}else {
$website = test_input($_POST["website"]);
}
if (empty($_POST["comment"])) {
$comment = "";
}else {
$comment = test_input($_POST["comment"]);
}
if (empty($_POST["gender"])) {
$genderErr = "Gender is required";
}else {
$gender = test_input($_POST["gender"]);
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<tr>
<td>E-mail: </td>
<td><input type = "text" name = "email">
<span class = "error">* <?php echo $emailErr;?></span>
</td>
</tr>
<tr>
<td>Time:</td>
<td> <input type = "text" name = "website">
<span class = "error"><?php echo $websiteErr;?></span>
</td>
</tr>
<tr>
<td>Classes:</td>
<td> <textarea name = "comment" rows = "5" cols = "40"></textarea></td>
</tr>
<tr>
<td>Gender:</td>
<td>
<input type = "radio" name = "gender" value = "female">Female
<input type = "radio" name = "gender" value = "male">Male
<span class = "error">* <?php echo $genderErr;?></span>
</td>
</tr>
<td>
<input type = "submit" name = "submit" value = "Submit">
</td>
</table>
</form>
<?php
echo "<h2>Your given values are as:</h2>";
echo $email;
echo "<br>";
echo $website;
echo "<br>";
echo $comment;
echo "<br>";
echo $gender;
?>
</body>
</html>
OUTPUT:
RESULT:
Thus the form of database has been created successfully.
AIM:
To create a web service in java to collect people’s opinion about a product to predict its
sale.
PROCEDURE:
1.Install Netbeans IDE
STEPS TO CREATE WEBSERVICE
1. Create project
Open Netbeans >> Select File >> New Project >> Java Web -> Web Application:
Click Next >> Enter Project name: ‘WC1’:
Click Next >> Select Server->Click Finish
2. Create WebService
Right click on the project ‘wc1’ >> New >> Web Service:
Enter Web service name: two-Enter Package: com.prgguru.example
Click Finish
3. Adding an Operation to the Web Service
The NetBeans IDE provides a dialog for adding an operation to a web service. Right Click
the ‘two’ webservice. Click Add Operation. The Add Operation dialog opens Add Operation
dialog box, type FeedBack in Name and type String in the Return Type drop-down list.
4. In the lower part of the Add Operation dialog box, click Add and create a parameter of
type int named Name,City,Comment as String type.
5. Click OK at the bottom of the Add Operation dialog box. You return to the editor.
SAMPLE PROGRAM:
Product.html
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<center>People's Opinion Form</center>
<form name="f1" action="http://localhost:8080/product/process.jsp" method="GET">
Name:<input type="text" name="t1" ><br>
City:<input type="text" name="t2" ><br>
Opinion:
<input type="radio" name="t3" value="GooD">Good
Process.jsp
RESULT:
Thus the web service has been created successfully.