Professional Documents
Culture Documents
Full Experiment
Full Experiment
map.html
<html>
<body>
<p>
<b>
</p>
</map>
<p><b>Note:</b>Some planets from our solar system are displayed here. click on any planet
and you will get some information about them.
</p>
</body>
</html>
m.html
<html>
<body>
</body>
</html>
s.html
<html>
<body>
Saturn cannot contain any living organisms in it as it contains poisonous gas at its
atmosphere.
</body>
</html>
v.html
<html>
<body>
</body>
</html>
e.html
<html>
<body>
</body>
</html>
embedded.html
<html xmlns="http//www.w3.org/199/xhtml">
<head>
<style type="text/css">
h1
font_family:arial;
color:GREEN;
h2
font_family:arial;
color:RED;
left:20px;
h3
font_family:arial;
color:BLUE;
h4
font_family:arial;
color:YELLOW;
<body bgcolor=VIOLET>
</head>
<h1>
<center>
</center>
</h1>
<h2>
</h2>
<h4>
</h4>
<h3>
</h3>
</body>
</html>
external.html
<html xmlns="http://www.w3.org/199/xhtml">
<head>
<body bgcolor="skyblue">
</head>
<h1 class="special">
</center>
</h1>
<h2>
</h2>
<p>
</p>
<h3>
</h3>
</body>
</html>
inline.html
<html><body bgcolor="gray">
</html>
UserInfo.xml
<?xml version="1.0">
<student>
<person-details>
<id>101</id>
<name>akash</name>
<city>chennai</city>
<marks>70</marks>
</person-details>
<person-details>
<id>102</id>
<name>abhi</name>
<city>madurai</city>
<marks>75</marks>
</person-details>
<person-details>
<id>103</id>
<name>bharathi</name>
<city>chennai</city>
<marks>95</marks>
</person-details>
<person-details>
<id>104</id>
<name>chitra</name>
<city>trichy</city>
<marks>80</marks>
</person-details>
<person-details>
<id>105</id>
<name>nancy</name>
<city>chennai</city>
<marks>85</marks>
</person-details>
<person-details>
<id>106</id>
<name>Dorathi</name>
<city>chennai</city>
if(key_id.match( x[i].getElementsByTagName("id")[0].childNodes[0].nodeValue ))
j=i;
}
document.write("<h3>Student details..</h3>");
document.write("<table
border='3'><tr><th>ID</th><th>NAME</th><th>CITY</th><th>MARKS</th></tr>");
document.write("<tr><td>");
document.write(x[j].getElementsByTagName("id")[0].childNodes[0].nodeValue );
document.write("</td><td>");
document.write(x[j].getElementsByTagName("name")[0].childNodes[0].nodeValue );
document.write("</td><td>");
document.write(x[j].getElementsByTagName("city")[0].childNodes[0].nodeValue );
document.write("</td><td>");
document.write(x[j].getElementsByTagName("marks")[0].childNodes[0].nodeValue );
document.write("</td></tr>");
document.write("</table>");
import java.io.*;
import java.net.*;
try
String Request="www.google.com";
Get_Web_Page(client_Socket);
catch (UnknownHostException e)
catch (IOException e)
try
String input_txt;
System.out.println(input_txt);
break;
output.close();
input.close();
client_Socket.close();
catch (Exception e)
import java.io.*;
import java.net.*;
try
catch (UnknownHostException e)
catch (IOException e)
System.out.println(e.getMessage());
if (smtpSocket != null)
output.writeBytes( "HELO\n" );
output.writeBytes( "DATA\n" );
output.writeBytes( "From:puntambekar.a@gmail.com\n" );
output.writeBytes( "QUIT" );
String response;
if (response.indexOf("OK") != -1)
break;
output.close();
input.close();
smtpSocket.close();
catch (UnknownHostException e)
catch (IOException e)
POP3:
import java.net.*;
import java.io.*;
Socket soc;
PrintStream output;
DataInputStream input;
String response;
try
soc=new Socket("202.137.237.142",8080);
response=input.readLine();
output.println("USER xyz");
response=input.readLine();
output.println("PASS blabla");
response=input.readLine();
output.println("LIST 1");
output.println("RETR 1");
response=input.readLine();
output.println("QUIT");
response=input.readLine();
soc.close();
catch(Exception e)
Welcome.txt
import java.io.*;
import java.util.*;
import java.net.*;
throws IOException
byte sendbuffer[]=msg.getBytes();
server_Socket.send(new
DatagramPacket(sendbuffer,sendbuffer.length,InetAddress.getLocalHost(),port_Number));
byte sendbuffer[]=msg.getBytes();
Iterator itr=portNoList.iterator();
while(itr.hasNext())
String strPortNo=(String)itr.next();
int portNo=Integer.parseInt(strPortNo);
if(Special_Port_Number!=portNo)
server_Socket.send(new
DatagramPacket(sendbuffer,sendbuffer.length,InetAddress.getLocalHost(),portNo));
try
server_Socket=new DatagramSocket(1024);
portNoList=new LinkedList();
portNos=new HashMap();
while(true)
server_Socket.receive(pkt);
if(clientMsg.indexOf("$##$")!=-1)
String clientName=st.nextToken();
String strPortNo=st.nextToken();
int clientPortNumber=Integer.parseInt(strPortNo);
portNoList.add(strPortNo);
portNos.put(clientName,strPortNo);
String clientName=st.nextToken();
String portNo=(String)portNos.get(clientName);
if(msg.indexOf("/exit")!=-1)
Send_Message("/exit",Integer.parseInt(portNo));
portNoList.remove(portNo);
portNos.remove(clientName);
sendToAll(msg,Integer.parseInt(portNo));
catch(Exception ex)
System.out.println(ex.getMessage());
import java.io.*;
import java.net.*;
try
client_Port=(int)(50000*Math.random());
while(true)
try
client_Socket=new DatagramSocket(client_Port);
catch(BindException e)
client_Port=(int)(50000*Math.random());
while(client_Port<1023||client_Port>65536)
client_Port=(int)(50000 * Math.random());
continue;
break;
String client_name=buff.readLine();
byte sendBuffer[]=Start_Msg.getBytes();
client_Socket.connect(InetAddress.getLocalHost(),1024);
client_Socket.send(new DatagramPacket(sendBuffer,sendBuffer.length));
th.start();
while(true)
String msg=buff.readLine();
sendBuffer=msg.getBytes();
client_Socket.send(new DatagramPacket(sendBuffer,sendBuffer.length));
break;
th.join();
buff.close();
}catch(Exception e) {System.out.println(e.getMessage());}
finally
client_Socket.close();
while(true)
try
client_Socket.receive(pkt);
catch(IOException e)
e.printStackTrace();
if(msg.indexOf("/exit")!=-1)
break;
System.out.println(msg + "\n");
C) Select new and set the following path, then click OK.
B) Save the html and java files in the corresponding folder as shown below
Filename.html
WEB-INF(folder)
a. Web.xml
b. Classes(folder)
Filename.java
C) Select new and set the following path, then click OK.
WEB-INF(folder)
a) Web.xml
b) Classes(folder)
Filename.java
Step1: Create a servlet in which some string is created for sending it to applet and compile
the program. The Generated class file will be saved in Classes Folder.
Step3: Now create an applet program which invokes the servlet created in step1 and compile
the Program.
Step4: Execute it Using Appletviewer and the Applet will be loaded which displays the
message obtained from the Servlet.
Web.xml
<web_app>
<servlet>
<servlet_name>Applet</servlet_name>
<servlet_class>MyServer</servlet_class>
</servlet>
<servlet_mapping>
<servlet_name>Applet</servlet_name>
<url_pattern>/MyServer</url_pattern>
</servlet_mapping>
</web_app>
1) Creating Database
a) Click Start Programs MS Office MS Access.
b) Select File New Blank Database and save it as Student Database
c) A database window appears. Select create table in design view option.
d) In the table window, enter the fields name and their respective data types.
e) The table is thus created.
f) Select the table and enter the records.
g) Save the table ad data1.
<%
String SeatNum,Name;
String ans1,ans2,ans3,ans4,ans5;
int a1,a2,a3,a4,a5;
a1=a2=a3=a4=a5=0;
Connection connect=null;
Statement stmt=null;
ResultSetrs=null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:StudentDB1";
connect=DriverManager.getConnection(url,"","");
if(request.getParameter("action")!=null)
SeatNum=request.getParameter("Seat_no");
Name=request.getParameter("Name");
ans1=request.getParameter("group1");
if(ans1.equals("True"))
a1=2;
else
a1=0;
ans2=request.getParameter("group2");
if(ans2.equals("True"))
else
a2=2;
ans3=request.getParameter("group3");
if(ans3.equals("True"))
a3=0;
else
a3=2;
ans4=request.getParameter("group4");
if(ans4.equals("True"))
a4=2;
else
a4=0;
ans5=request.getParameter("group5");
if(ans5.equals("True"))
a5=0;
else
a5=2;
int Total=a1+a2+a3+a4+a5;
stmt=connect.createStatement();
int result=stmt.executeUpdate(query);
stmt.close();
stmt=connect.createStatement();
rs=stmt.executeQuery(query);
<body bgcolor=khaki>
<center>
<h2>Students Marksheet</h2>
<tr>
<td><b>Seat_No</b></td>
<td><b>Name</b></td>
<td><b>Marks</b><td>
</tr>
<%
while(rs.next())
%>
<tr>
<td><%=rs.getInt(1)%></td>
<td><%=rs.getString(2)%></td>
<td><%=rs.getString(3)%></td>
</tr>
<%
rs.close();
stmt.close();
connect.close();
%>
</center>
<br/><br/><br/>
<table>
<tr><td><b>Date:<%=new java.util.Date().toString()%></td></tr>
<tr><td><b>Signature:X.Y.Z.<b></td></tr>
</table>
<div>
</body>
</html>
<%}else{%>
<html>
<head>
<script language="javascript">
function validation(Form_obj)
if(Form_obj.Seat_no.value.length==0)
Form_obj.Seat_no.focus();
return false;
if(Form_obj.Name.value.length==0)
Form_obj.Name.focus();
return false;
}return true;
</script>
</head>
<body bgcolor=lightgreen>
<center>
</center>
<table>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr></table>
<br/>
<br/>
<br/>
<br/>
<br/>
<center>
</center>
</form>
<%}%>
C) Select new and set the following path, then click OK.
B) Save the html and java files in the corresponding folder as shown below
Filename.html
WEB-INF(folder)
c. Web.xml
d. Classes(folder)
Filename.java
<html>
<head>
<title>Input Form</title>
</head>
<body>
<center>
<table>
<tr>
<td><b>Enter Key</b></td>
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
import java.io.*;
import java.net.*;
importjava.util.*;
importjavax.servlet.*;
res.setContentType("text/plain");
PrintWriter out=res.getWriter();
String userKey=req.getParameter("user_key");
String key=getInitParameter("key");
String host=req.getServerName();
String HostIP="";
long result=0;
int port=req.getServerPort();
if(key==null)
out.println("*********");
try
InetAddress IP=InetAddress.getLocalHost();
HostIP=IP.getHostAddress();
String[] ipAddressInArray=HostIP.split("\\.");
longip=Long.parseLong(ipAddressInArray[3-i]);
result |= ip<<(i*8);
result=result+port;
catch(UnknownHostException e)
out.println(e);
long k=Long.parseLong(userKey);
if(k==result)
else
}}
<servlet>
<init-param>
<param-name>key</param-name>
<param-value>3232267905</param-value>
</init-param>
<servlet-name>keyIPLock</servlet-name>
<servlet-class>keyIPLock</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>keyIPLock</servlet-name>
<url-pattern>/servlet/keyIPLock</url-pattern>
</servlet-mapping>
C) Select new and set the following path, then click OK.
B) Save the html and java files in the corresponding folder as shown below
Filename.html
WEB-INF(folder)
e. Web.xml
f. Classes(folder)
Filename.java
Web.xml
<web-app>
<servlet>
<servlet-name>Ses29</servlet-name>
<servlet-class>Ses29</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Ses29</servlet-name>
<url-pattern>/Ses29</url-pattern>
</servlet-mapping>
</web-app>
C) Select new and set the following path, then click OK.
B) Save the html and java files in the corresponding folder as shown below
Filename.html
WEB-INF(folder)
1) Web.xml
2) Classes(folder)
Filename.java
<html>
<head>
<body>
<div align="center">
<br><br>
<form action="http://localhost:8080/suraj/servlet/LoginServlet"method="post">
Enter Username:
<input type="text"value=""name="User">
<br><br>Enter password:
<input type="password"value=""name="Password">
<br><br>Enter CardID:
<input type="text"value=""name=CardID">
<br><br><br>
<input type="submit"value="Login">
</form>
</div>
</body>
</html>
LoginServlet.java
import java.io.*;
importjavax.servlet.*;
importjavax.servlet.http.*;
ServletException,IOException
res.setContentType("text/html");
PrintWriter out=res.getWriter();
String usr=req.getParameter("User");
String pwd=req.getParameter("Password");
String card=req.getParameter("CardID");
boolean flag=true;
String[] userID=getInitParameter("usernames").split(",");
String[] password=getInitParameter("passwords").split(",");
String[] cardids=getInitParameter("cardIDs").split(",");
inti;
for(i=0;i<userID.length;i++)
if(userID[i].equals(usr)&&password[i].equals(pwd)&&cardids[i].equals(card))
flag=true;
MyCookie.setMaxAge(60*60);
res.addCookie(MyCookie);
res.sendRedirect("http://localhost:8080/suraj/servlet/LoginSucess");
if(flag==false)
LoginSuccess.java
import java.io.*;
importjavax.servlet.*;
importjavax.servlet.http.*;
throwsServletException,IOException
Cookie[] my_cookies=req.getCookies();
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.println("<br>");
String userName=null;
if(my_cookies!=null)
for(Cookie cookie:my_cookies)
if(cookie.getName().equals("CurrentUser"));
userName=cookie.getValue();
out.close();
Web.xml
<servlet>
<init-param>
<param-name>usernames</param-name>
<param-value>user1,user2,user3</param-value>
</init-param><init-param>
<param-name>passwords</param-name>
<param-value>pwd1,pwd2,pwd3</param-value>
</init-param>
<init-param>
<param-name>cardIDs</param-name>
<param-value>111,222,333</param-value>
</init-param>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/servlet/LoginServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-class>LoginSuccess</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginSuccess</servlet-name>
<url-pattern>/servlet/LoginSuccess</url-pattern>
</servlet-mapping>
AIM:
PROCEDURE :-
Step1:- Open the Netbeans6.9.1 IDE from desktop.
Step2:- Select file->new project. From categories, choose java weband from projects, select
web application. Click next->give name as Strutsdemo->click next.
Step 3:- Select the server as tomcat5.5 and give the user name and password. ->click next.
Step 4:- Select the framework as Struts 1.3.10. ->click finish.This creates one project
Strutsdemo in the project window.
Step5:- In the structure of the Strutsdemo from the project window select index.jsp and
web.xml verify the contents of those files.
Step6:- In the structure of the Strutsdemo from the project window select source packages-
>Applicationresource.properties.Then specify the content to be displayed on the web page in
the welcome message field
AIM:
PROCEDURE:
Step1:- Open the Netbeans6.9.1 IDE from desktop.
Step2:- Select file->new project. From categories, choose java weband from projects, select
web application. Click next->give name as springdemo->click next.
Step 4:- Select the framework as Spring Framework 4.0.1 ->click finish.This creates one
project Strutsdemo in the project window.
Step5:- In the structure of the springdemo from the project window select web.xml
.verify the contents of that file
Step6:- In the structure of the springdemo from the project window select index.jsp .Then
specify the content to be displayed on the web page
Step7:- Start the GlassfishV3 server .In service window select server->right click on
GlassfishV3 and click start
AIM:
PROCEDURE :-
Step1:- Open the Netbeans6.9.1 IDE from desktop.
Step2:- Select file->new project. From categories, choose java weband from projects, select
web application. Click next->give name as hibernatedemo->click next.
Step 4:- Select the framework as Spring Framework 4.0.1 ->click finish.This creates one
project Strutsdemo in the project window.
Step5:- In the structure of the hibernatedemo from the project window select web.xml verify
the contents of that file.
Step6:- In the structure of the hibernatedemo from the project window select index.jsp
.Then specify the content to be displayed on the web page.
Step7:- Start the GlassfishV3 server .In service window select server->right click on
GlassfishV3 and click start.
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function()
$("button").click(
function()
$("p").hide();
);
});
</script>
</head>
<body>
<p>this is paragraph</p>
<button>click</button>
</body>
</html>