SlideShare a Scribd company logo
1 of 10
1.a(cgi)
#!/usr/bin/perl
print”content-type: text/html”,”nn”;
print”<html>”,”n”;
print”<head><title>ABOUT THE SERVER</head></title>”,”n”;
print”<body><h1>ABOUT THIS SERVER</h1>”,”n”;
print”<hr><pre>”;
print”Server Name:”,$ENV{”SERVER_NAME”},”<br>”,”n”;
print”Running on Port:”,$ENV{”SERVER_PORT”},”<br>”,”n”;
print”Server Software:”,$ENV{”SERVER_SOFTWARE”},”<br>”,”n”;
print”Server Protocol:”,$ENV{”SERVER_PROTOCOL”},”<br>”,”n”;
print”CGI Revision:”,$ENV{”GATEWAY_INTERFACE”},”<br>”,”n”;
print”</body></html>”,”n”;
exit(0);
1.b(Cgi)
#!/usr/bin/perl
use strict;
use CGI':standard';
print"content-type: text/html","nn";
my$v1=param('unixcom');
print"command: $v1","n";
print"Result:n";
my$res=system("$v1");
if($res!=0)
{
print"INVALID COMMAND KINDLY ENTER A VALID CMD!!!n";
}
1b(html)
<html>
<head><title>enter the unix command</title>
</head>
<body>
<hr>
<form action="/ cgi-bin/1bprg.cgi"method="get">
<h3>enter the unix command</h3>
<INPUT type= "text" name="unixcom">
<br>
<br>
<INPUT type="submit" value="submit">
<INPUT type="reset" value="reset">
</form>
</body>
</html>
2.a(cgi)
#! /usr/bin/perl print "content-type: text/htmlnn";
$qstr=$ENV{"QUERY_STRING"}; ($field,$cmd)=split(/=/,$qstr); $cmd=~ s/+/ /g;
print "Hello ",$cmd; print "nnWelcome to CSE Lab, Dept of CSE,UVCEnn"; print
"nnHave a nice day!!!";
2.b(cgi)
#! /usr/bin/perl print "content-type : text/htmlnn"; $filename="counter.txt";
if(open(FILE1,"<",$filename)) { $counter=<FILE1>; } else { $counter=0; }
close(FILE1); $counter++; print "Total number of page hits : ",$counter."n";
if( open(FILE1,">",$filename) ) { print FILE1 $counter; } else { print "File
does not exist..."; } close(FILE1);
3(cgi)
#! /usr/bin/perl print "content-type : text/htmlnn"; ($seconds, $minutes,
$hour) = localtime (time); if ( ($hour >= 23) || ($hour <= 6) )
{ $greeting = "Wow, you are up late"; } elsif ( ($hour > 6) && ($hour <
12) ) { $greeting = "Good Morning"; } elsif ( ($hour >= 12) && ($hour <=
18) ) { $greeting = "Good Afternoon"; } else { $greeting = "Good
Evening"; } print "Welcome User !!!n",$greeting."n";
$qstr=$ENV{"QUERY_STRING"}; ($field,$cmd)=split(/=/,$qstr); $webmaster=$cmd;
#$webmaster="asd"; open(FILE1, "/usr/bin/w -h -s $webmaster |"); if (<FILE1>
=~ /$webmaster/) { $in_out = "The webmaster is currently logged
in!!!n"; } else { $in_out = "The webmaster is not currently logged
in!!!n"; } print <FILE1>; close(FILE1); print "n".$in_out."n";
3(html)
<html>
<body>
<form action ="/cgi-bin/h.pl" method="GET">
enter the webmasters name:
<input type ="text" name="t1" size=20>
<input type ="submit" value ="submit">
</form>
</body>
</html>
4(cgi)
#!/usr/bin/perl
print "content-type:text/html nn";
print "<html> <head> <meta http-equiv=refresh content=1 www.goole.com> </head>
</html>";
print "current time is ";
($seconds, $minutes, $hour) = localtime(time);
print "$hour:$minutes:$seconds";
if($hour<12)
{
$var=AM;
}
else
{
$hour=12-$hour;
$var=PM;
}
print "nncurrent time is :";
print "$hour:$minutes:$seconds:$var";
5(cgi)
#!/opt/lampp/bin/perl
print "content-type:text/html nn";
use DBI;
use CGI ':standard';
$db=DBI->connect("DBI:mysql:rajeev1","root","");
$query=$db->prepare("select * from student");
$query->execute;
while(@row=$query->fetchrow)
{
print "$row[0] $row[1] $row[2] <br>";}
$query->finish;
$db->disconnect;
6(cgi)
#! /opt/lampp/bin/perl
use DBI;
use CGI ':standard';
$db=DBI->connect("DBI:mysql:ravidb1","root","");
$name=param("txtname");
$age=param("txtage");
$addr=param("txtaddr");
$querytxt="insert into ravitab1 values('$name',$age,'$addr')";
$query=$db->prepare($querytxt);
$query->execute;
$query->finish;
$db->disconnect;
print "content-type:text/html nn";
print "<br><b>The record was successfully inserted...";
6(html)
<html> <body> <form action="/cgi-bin/r6.pl" method="get"> name <input
type="text" name="txtname" size=10> <br> age: <input type="text" name="txtage"
size=2> <br> addr <input type="text" name="txtaddr" size=15> <br> <input
type="submit" value="submit"> </form> </body> </html>
7(PHP)
<html>
<body>
<table border=1> <tr> <td><b>NAME</td> <td><b>AGE</td> <td><b>ADDRESS</td> </tr>
<?
$username="root";
$password="";
$database="ravidb1";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM ravitb1";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
echo "<tr>";
$name=mysql_result($result,$i,"name");
$age=mysql_result($result,$i,"age");
$addr=mysql_result($result,$i,"addr");
echo "<td>";
echo $name;
echo "</td>";
echo "<td>";
echo $age;
echo "</td>";
echo "<td>";
echo $addr;
echo "</td>";
echo "</tr>";
$i++;
}
?>
</table>
8(php)
<?
$accid=$_GET['txtaccid'];
$title=$_GET['txttitle'];
$authors=$_GET['txtauthors'];
$edition=$_GET['txtedition'];
$pub=$_GET['txtpub'];
$username="root";
$password="";
$database="ravidb1";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="insert into books values ($accid,'$title','$authors',$edition,'$pub')";
$result=mysql_query($query);
mysql_close();
?>
<b>The record was inserted successfully...</b>
8(html)
<html>
<body>
<b> Welcome to the Books database.</b> <br>
<b> To enter a record, fill in the details and click submit...</b><br><br>
<form action="r8.php" method="get">
<b>Enter the book's accession Id ==> </b>
<input type="text" name="txtaccid"><br><br>
<b>Enter the book's title ==> </b>
<input type="text" name="txttitle"><br><br>
<b>Enter the book's authors ==> </b>
<input type="text" name="txtauthors"><br><br>
<b>Enter the book's edition ==> </b>
<input type="text" name="txtedition"><br><br>
<b>Enter the book's publication ==> </b>
<input type="text" name="txtpub"><br><br>
<input type="submit" value="Insert">
<input type="reset" value="Reset">
</form>
9(PHP)
<html>
<body>
<table border=1>
<tr> <td><b>Accession Number</td> <td><b>Title</td> <td><b>Authors</td>
<td><b>Edition</td>
<td><b>Publication</td> </tr>
<?
$username="root";
$password="";
$database="ravidb1";
$title=$_GET['txttitle'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM books where title='$title'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
echo "<tr>";
$accid=mysql_result($result,$i,"accno");
$title=mysql_result($result,$i,"title");
$authors=mysql_result($result,$i,"authors");
$edition=mysql_result($result,$i,"edition");
$pub=mysql_result($result,$i,"publication");
echo "<td>";
echo $accid;
echo "</td>";
echo "<td>";
echo $title;
echo "</td>";
echo "<td>";
echo $authors;
echo "</td>";
echo "<td>";
echo $edition;
echo "</td>";
echo "<td>";
echo $pub;
echo "</td>";
echo "</tr>";
$i++;
}
?>
</table>
</body>
</html>
9(html)
<html>
<body>
<b> Welcome to the Books database.</b> <br>
<b> To search for a book, fill in it's title and click search...</b><br><br>
<form action="r9.php" method="get">
<b>Enter the book's Title ==> </b>
<input type="text" name="txttitle"><br><br>
<input type="submit" value="Search">
<input type="reset" value="Reset">
</form>
10.a(jsp)
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class pro22a extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws IOException,ServletException
{
response.setContentType("text/html");
PrintWriter out=response.getWriter();
//String co=request.getParameter("cn");
out.println("<html>");
out.println("<head>");
out.println("<title>hello world</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>hello</h1>"+request.getParameter("cn"));
out.println("request method is "+request.getMethod());
out.println("uri is "+request.getRequestURI());
out.println("protocol is "+request.getProtocol());
out.println("remote addr is"+request.getRemoteAddr());
out.println("</body>");
out.println("</html>");
}
}
10.a(html)
<html>
<body>
<form action="http://localhost:8080/servlet/pro22a" method="GET">
<h1> welcome </h1>
enter username:
<input name="cn" type="text">
<input type="submit" value="submit">
</form>
</body>
</html>
10.b(jsp)
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class pro2b extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws IOException,ServletException
{
response.setContentType("text/html");
PrintWriter out=response.getWriter();
String co=request.getParameter("cn");
out.println("<html>");
out.println("<head>");
out.println("<title>hello world</title>");
out.println("</head>");
out.println("<body bgcolor="+co+">");
out.println("<h1>hello</h1>");
out.println("request method is "+request.getMethod());
out.println("uri is "+request.getRequestURI());
out.println("protocol is "+request.getProtocol());
out.println("remote addr is"+request.getRemoteAddr());
out.println("</body>");
out.println("</html>");
}
}
10.b(html)
<html
<body>
<form action="http://localhost:8080/servlet/pro2b" method="GET">
<h1> welcome </h1>
<select name="cn">
<option value="indigo">indigo</option>
<option value="green">green</option>
<option value="blue" selected="selected">blue</option>
</select>
<input type="submit" value="submit">
</form>
</body>
</html>
11(jsp)
import java.io.*;
import javax.servlet.*;
import java.util.*;
import javax.servlet.http.*;
public class prog11 extends HttpServlet{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws
IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
String str=new String();
Calendar cl=Calendar.getInstance();
int hr=cl.get(Calendar.HOUR_OF_DAY);
if(hr>=0 && hr<12)
{
out.println("Good Morning.....");
}
if(hr>=12 && hr<16)
{
out.println("Good Afternoon...");
}
if(hr>=16 && hr<20)
{
out.println("Good Evening...");
}
if(hr>=20){
out.println("GO to Sleep.....");
}}}
12(jsp)
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class newcookies extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws
IOException, ServletException
{
PrintWriter out=res.getWriter();
Cookie[] cookies_list = req.getCookies();
String name=req.getParameter("txtname");
String val=req.getParameter("txtval");
res.setContentType("text/html");
out.println("<html>");
if(name==null)
{
if(cookies_list!=null)
{
out.println("Cookies Stored!!!");
int i;
for(i=0;i<cookies_list.length;i++)
out.println(cookies_list[i].getName() + ":" + cookies_list[i].getValue() +
"<br>");
}
out.println("<form action=http://localhost:8080/servlet/newcookies
method=get>");
out.println("Enter the name ... <input name=txtname>");
out.println("Enter the value ... <input name=txtval>");
out.println("<input type=submit value=submit>");
out.println("</form> </html>");
}
else if(name!=null)
{
Cookie cookName=new Cookie(name,val);
res.addCookie(cookName);
out.println("Cookies submitted successfully!!!");
}
}
}
13(jsp)
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class prog13 extends HttpServlet{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws
IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
HttpSession hs=req.getSession(true);
out.println("Session ID:"+hs.getId());
Date d1=new Date(hs.getCreationTime());
out.println("<br>Creation Time:"+d1);
Date d2=new Date(hs.getLastAccessedTime());
out.println("<br>Last Access Time:"+d2);
}
}
14(jsp)
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class pro14 extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws IOException,ServletException
{
response.setContentType("text/html");
PrintWriter out=response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>hello world</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>hello</h1>");
out.println("request method is "+request.getMethod());
out.println("uri is "+request.getRequestURI());
out.println("protocol is "+request.getProtocol());
out.println("remote addr is"+request.getRemoteAddr());
out.println("</body>");
out.println("</html>");
}
}
15(jsp)
/* 15. Program to accept username and address and display them in a web
page by passing parameters. */
import java.lang.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class prg15 extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException,IOException
{
PrintWriter out=res.getWriter();
out.println("<html>");
out.println("<head><title>Program 15 </title></head>");
out.println("<body>");
out.println("<h1>User Information</h1>");
out.println("<br><hr><br>");
out.println("<form method=post action=/servlet/prg15");
out.println("Dear User.<br>");
out.println("Please Enter the following Information.<br><br>");
out.println("UserName: <input type=text name=username
value=""><br><br>");
out.println("Address: <input type=text name=address
value=""><br><br>");
out.println("<input type=submit value=Submit><input type=reset
value=Clear>");
out.println("</form>");
out.println("</body></html>");
}
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException,IOException
{
PrintWriter out=res.getWriter();
String username=req.getParameter("username");
String address=req.getParameter("address");
out.println("<html>");
out.println("<head><title>Program 15 </title></head>");
out.println("<body>");
out.println("<h1>User Information</h1>");
out.println("<br><hr><br>");
out.println("Dear User.<br>");
out.println("Your Information.<br><br>");
out.println("UserName: "+username+"<br>");
out.println("Address :"+address+"<br>");
out.println("<br><center><a
href=/servlet/prg15>Back</a></center>");
out.println("</body>");
out.println("</html>");
}
}

More Related Content

What's hot

Not Really PHP by the book
Not Really PHP by the bookNot Really PHP by the book
Not Really PHP by the bookRyan Kilfedder
 
Working with web_services
Working with web_servicesWorking with web_services
Working with web_servicesLorna Mitchell
 
Web Development Course: PHP lecture 2
Web Development Course: PHP lecture 2Web Development Course: PHP lecture 2
Web Development Course: PHP lecture 2Gheyath M. Othman
 
Web Development Course: PHP lecture 4
Web Development Course: PHP  lecture 4Web Development Course: PHP  lecture 4
Web Development Course: PHP lecture 4Gheyath M. Othman
 
Quick beginner to Lower-Advanced guide/tutorial in PHP
Quick beginner to Lower-Advanced guide/tutorial in PHPQuick beginner to Lower-Advanced guide/tutorial in PHP
Quick beginner to Lower-Advanced guide/tutorial in PHPSanju Sony Kurian
 
神に近づくx/net/context (Finding God with x/net/context)
神に近づくx/net/context (Finding God with x/net/context)神に近づくx/net/context (Finding God with x/net/context)
神に近づくx/net/context (Finding God with x/net/context)guregu
 
Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101hendrikvb
 
SULTHAN's - PHP MySQL programs
SULTHAN's - PHP MySQL programsSULTHAN's - PHP MySQL programs
SULTHAN's - PHP MySQL programsSULTHAN BASHA
 
Introducation to php for beginners
Introducation to php for beginners Introducation to php for beginners
Introducation to php for beginners musrath mohammad
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworksdiego_k
 
If love is_blind_-_tiffany
If love is_blind_-_tiffanyIf love is_blind_-_tiffany
If love is_blind_-_tiffanytenka
 
Webrtc mojo
Webrtc mojoWebrtc mojo
Webrtc mojobpmedley
 

What's hot (19)

Not Really PHP by the book
Not Really PHP by the bookNot Really PHP by the book
Not Really PHP by the book
 
Working with web_services
Working with web_servicesWorking with web_services
Working with web_services
 
php part 2
php part 2php part 2
php part 2
 
B03-GenomeContent-Intermine
B03-GenomeContent-IntermineB03-GenomeContent-Intermine
B03-GenomeContent-Intermine
 
Web Development Course: PHP lecture 2
Web Development Course: PHP lecture 2Web Development Course: PHP lecture 2
Web Development Course: PHP lecture 2
 
Web Development Course: PHP lecture 4
Web Development Course: PHP  lecture 4Web Development Course: PHP  lecture 4
Web Development Course: PHP lecture 4
 
Quick beginner to Lower-Advanced guide/tutorial in PHP
Quick beginner to Lower-Advanced guide/tutorial in PHPQuick beginner to Lower-Advanced guide/tutorial in PHP
Quick beginner to Lower-Advanced guide/tutorial in PHP
 
Php with my sql
Php with my sqlPhp with my sql
Php with my sql
 
Fun with Python
Fun with PythonFun with Python
Fun with Python
 
神に近づくx/net/context (Finding God with x/net/context)
神に近づくx/net/context (Finding God with x/net/context)神に近づくx/net/context (Finding God with x/net/context)
神に近づくx/net/context (Finding God with x/net/context)
 
Postman On Steroids
Postman On SteroidsPostman On Steroids
Postman On Steroids
 
Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101
 
SULTHAN's - PHP MySQL programs
SULTHAN's - PHP MySQL programsSULTHAN's - PHP MySQL programs
SULTHAN's - PHP MySQL programs
 
Web Scrapping with Python
Web Scrapping with PythonWeb Scrapping with Python
Web Scrapping with Python
 
Introducation to php for beginners
Introducation to php for beginners Introducation to php for beginners
Introducation to php for beginners
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
 
If love is_blind_-_tiffany
If love is_blind_-_tiffanyIf love is_blind_-_tiffany
If love is_blind_-_tiffany
 
C++
C++C++
C++
 
Webrtc mojo
Webrtc mojoWebrtc mojo
Webrtc mojo
 

Similar to Ip lab

Practical PHP by example Jan Leth-Kjaer
Practical PHP by example   Jan Leth-KjaerPractical PHP by example   Jan Leth-Kjaer
Practical PHP by example Jan Leth-KjaerCOMMON Europe
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHPNat Weerawan
 
Grok Drupal (7) Theming
Grok Drupal (7) ThemingGrok Drupal (7) Theming
Grok Drupal (7) ThemingPINGV
 
Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4DEVCON
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivityMouli Chandira
 
Ch1(introduction to php)
Ch1(introduction to php)Ch1(introduction to php)
Ch1(introduction to php)Chhom Karath
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with PerlDave Cross
 
Python Code Camp for Professionals 4/4
Python Code Camp for Professionals 4/4Python Code Camp for Professionals 4/4
Python Code Camp for Professionals 4/4DEVCON
 
PHP an intro -1
PHP an intro -1PHP an intro -1
PHP an intro -1Kanchilug
 

Similar to Ip lab (20)

PHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
 
Practical PHP by example Jan Leth-Kjaer
Practical PHP by example   Jan Leth-KjaerPractical PHP by example   Jan Leth-Kjaer
Practical PHP by example Jan Leth-Kjaer
 
Pp checker
Pp checkerPp checker
Pp checker
 
Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
 
Hacking with hhvm
Hacking with hhvmHacking with hhvm
Hacking with hhvm
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHP
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Grok Drupal (7) Theming
Grok Drupal (7) ThemingGrok Drupal (7) Theming
Grok Drupal (7) Theming
 
JavaScript Training
JavaScript TrainingJavaScript Training
JavaScript Training
 
Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivity
 
Ch1(introduction to php)
Ch1(introduction to php)Ch1(introduction to php)
Ch1(introduction to php)
 
Php (1)
Php (1)Php (1)
Php (1)
 
PHP Tutorial (funtion)
PHP Tutorial (funtion)PHP Tutorial (funtion)
PHP Tutorial (funtion)
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
 
Practica n° 7
Practica n° 7Practica n° 7
Practica n° 7
 
Python Code Camp for Professionals 4/4
Python Code Camp for Professionals 4/4Python Code Camp for Professionals 4/4
Python Code Camp for Professionals 4/4
 
PHP an intro -1
PHP an intro -1PHP an intro -1
PHP an intro -1
 
Html , php, mysql intro
Html , php, mysql introHtml , php, mysql intro
Html , php, mysql intro
 
PHP code examples
PHP code examplesPHP code examples
PHP code examples
 

Recently uploaded

Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 

Recently uploaded (20)

Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 

Ip lab

  • 1. 1.a(cgi) #!/usr/bin/perl print”content-type: text/html”,”nn”; print”<html>”,”n”; print”<head><title>ABOUT THE SERVER</head></title>”,”n”; print”<body><h1>ABOUT THIS SERVER</h1>”,”n”; print”<hr><pre>”; print”Server Name:”,$ENV{”SERVER_NAME”},”<br>”,”n”; print”Running on Port:”,$ENV{”SERVER_PORT”},”<br>”,”n”; print”Server Software:”,$ENV{”SERVER_SOFTWARE”},”<br>”,”n”; print”Server Protocol:”,$ENV{”SERVER_PROTOCOL”},”<br>”,”n”; print”CGI Revision:”,$ENV{”GATEWAY_INTERFACE”},”<br>”,”n”; print”</body></html>”,”n”; exit(0); 1.b(Cgi) #!/usr/bin/perl use strict; use CGI':standard'; print"content-type: text/html","nn"; my$v1=param('unixcom'); print"command: $v1","n"; print"Result:n"; my$res=system("$v1"); if($res!=0) { print"INVALID COMMAND KINDLY ENTER A VALID CMD!!!n"; } 1b(html) <html> <head><title>enter the unix command</title> </head> <body> <hr> <form action="/ cgi-bin/1bprg.cgi"method="get"> <h3>enter the unix command</h3> <INPUT type= "text" name="unixcom"> <br> <br> <INPUT type="submit" value="submit"> <INPUT type="reset" value="reset"> </form> </body> </html> 2.a(cgi) #! /usr/bin/perl print "content-type: text/htmlnn"; $qstr=$ENV{"QUERY_STRING"}; ($field,$cmd)=split(/=/,$qstr); $cmd=~ s/+/ /g; print "Hello ",$cmd; print "nnWelcome to CSE Lab, Dept of CSE,UVCEnn"; print "nnHave a nice day!!!"; 2.b(cgi) #! /usr/bin/perl print "content-type : text/htmlnn"; $filename="counter.txt"; if(open(FILE1,"<",$filename)) { $counter=<FILE1>; } else { $counter=0; } close(FILE1); $counter++; print "Total number of page hits : ",$counter."n"; if( open(FILE1,">",$filename) ) { print FILE1 $counter; } else { print "File does not exist..."; } close(FILE1); 3(cgi) #! /usr/bin/perl print "content-type : text/htmlnn"; ($seconds, $minutes, $hour) = localtime (time); if ( ($hour >= 23) || ($hour <= 6) ) { $greeting = "Wow, you are up late"; } elsif ( ($hour > 6) && ($hour < 12) ) { $greeting = "Good Morning"; } elsif ( ($hour >= 12) && ($hour <= 18) ) { $greeting = "Good Afternoon"; } else { $greeting = "Good
  • 2. Evening"; } print "Welcome User !!!n",$greeting."n"; $qstr=$ENV{"QUERY_STRING"}; ($field,$cmd)=split(/=/,$qstr); $webmaster=$cmd; #$webmaster="asd"; open(FILE1, "/usr/bin/w -h -s $webmaster |"); if (<FILE1> =~ /$webmaster/) { $in_out = "The webmaster is currently logged in!!!n"; } else { $in_out = "The webmaster is not currently logged in!!!n"; } print <FILE1>; close(FILE1); print "n".$in_out."n"; 3(html) <html> <body> <form action ="/cgi-bin/h.pl" method="GET"> enter the webmasters name: <input type ="text" name="t1" size=20> <input type ="submit" value ="submit"> </form> </body> </html> 4(cgi) #!/usr/bin/perl print "content-type:text/html nn"; print "<html> <head> <meta http-equiv=refresh content=1 www.goole.com> </head> </html>"; print "current time is "; ($seconds, $minutes, $hour) = localtime(time); print "$hour:$minutes:$seconds"; if($hour<12) { $var=AM; } else { $hour=12-$hour; $var=PM; } print "nncurrent time is :"; print "$hour:$minutes:$seconds:$var"; 5(cgi) #!/opt/lampp/bin/perl print "content-type:text/html nn"; use DBI; use CGI ':standard'; $db=DBI->connect("DBI:mysql:rajeev1","root",""); $query=$db->prepare("select * from student"); $query->execute; while(@row=$query->fetchrow) { print "$row[0] $row[1] $row[2] <br>";} $query->finish; $db->disconnect; 6(cgi) #! /opt/lampp/bin/perl use DBI; use CGI ':standard'; $db=DBI->connect("DBI:mysql:ravidb1","root",""); $name=param("txtname"); $age=param("txtage"); $addr=param("txtaddr");
  • 3. $querytxt="insert into ravitab1 values('$name',$age,'$addr')"; $query=$db->prepare($querytxt); $query->execute; $query->finish; $db->disconnect; print "content-type:text/html nn"; print "<br><b>The record was successfully inserted..."; 6(html) <html> <body> <form action="/cgi-bin/r6.pl" method="get"> name <input type="text" name="txtname" size=10> <br> age: <input type="text" name="txtage" size=2> <br> addr <input type="text" name="txtaddr" size=15> <br> <input type="submit" value="submit"> </form> </body> </html> 7(PHP) <html> <body> <table border=1> <tr> <td><b>NAME</td> <td><b>AGE</td> <td><b>ADDRESS</td> </tr> <? $username="root"; $password=""; $database="ravidb1"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM ravitb1"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { echo "<tr>"; $name=mysql_result($result,$i,"name"); $age=mysql_result($result,$i,"age"); $addr=mysql_result($result,$i,"addr"); echo "<td>"; echo $name; echo "</td>"; echo "<td>"; echo $age; echo "</td>"; echo "<td>"; echo $addr; echo "</td>"; echo "</tr>"; $i++; } ?> </table>
  • 4. 8(php) <? $accid=$_GET['txtaccid']; $title=$_GET['txttitle']; $authors=$_GET['txtauthors']; $edition=$_GET['txtedition']; $pub=$_GET['txtpub']; $username="root"; $password=""; $database="ravidb1"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="insert into books values ($accid,'$title','$authors',$edition,'$pub')"; $result=mysql_query($query); mysql_close(); ?> <b>The record was inserted successfully...</b> 8(html) <html> <body> <b> Welcome to the Books database.</b> <br> <b> To enter a record, fill in the details and click submit...</b><br><br> <form action="r8.php" method="get"> <b>Enter the book's accession Id ==> </b> <input type="text" name="txtaccid"><br><br> <b>Enter the book's title ==> </b> <input type="text" name="txttitle"><br><br> <b>Enter the book's authors ==> </b> <input type="text" name="txtauthors"><br><br> <b>Enter the book's edition ==> </b> <input type="text" name="txtedition"><br><br> <b>Enter the book's publication ==> </b> <input type="text" name="txtpub"><br><br> <input type="submit" value="Insert"> <input type="reset" value="Reset"> </form> 9(PHP) <html> <body> <table border=1> <tr> <td><b>Accession Number</td> <td><b>Title</td> <td><b>Authors</td> <td><b>Edition</td> <td><b>Publication</td> </tr> <? $username="root"; $password=""; $database="ravidb1"; $title=$_GET['txttitle']; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database");
  • 5. $query="SELECT * FROM books where title='$title'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { echo "<tr>"; $accid=mysql_result($result,$i,"accno"); $title=mysql_result($result,$i,"title"); $authors=mysql_result($result,$i,"authors"); $edition=mysql_result($result,$i,"edition"); $pub=mysql_result($result,$i,"publication"); echo "<td>"; echo $accid; echo "</td>"; echo "<td>"; echo $title; echo "</td>"; echo "<td>"; echo $authors; echo "</td>"; echo "<td>"; echo $edition; echo "</td>"; echo "<td>"; echo $pub; echo "</td>"; echo "</tr>"; $i++; } ?> </table> </body> </html> 9(html) <html> <body> <b> Welcome to the Books database.</b> <br> <b> To search for a book, fill in it's title and click search...</b><br><br> <form action="r9.php" method="get"> <b>Enter the book's Title ==> </b> <input type="text" name="txttitle"><br><br> <input type="submit" value="Search"> <input type="reset" value="Reset"> </form> 10.a(jsp) import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class pro22a extends HttpServlet { public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
  • 6. { response.setContentType("text/html"); PrintWriter out=response.getWriter(); //String co=request.getParameter("cn"); out.println("<html>"); out.println("<head>"); out.println("<title>hello world</title>"); out.println("</head>"); out.println("<body>"); out.println("<h1>hello</h1>"+request.getParameter("cn")); out.println("request method is "+request.getMethod()); out.println("uri is "+request.getRequestURI()); out.println("protocol is "+request.getProtocol()); out.println("remote addr is"+request.getRemoteAddr()); out.println("</body>"); out.println("</html>"); } } 10.a(html) <html> <body> <form action="http://localhost:8080/servlet/pro22a" method="GET"> <h1> welcome </h1> enter username: <input name="cn" type="text"> <input type="submit" value="submit"> </form> </body> </html> 10.b(jsp) import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class pro2b extends HttpServlet { public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException { response.setContentType("text/html"); PrintWriter out=response.getWriter(); String co=request.getParameter("cn"); out.println("<html>"); out.println("<head>"); out.println("<title>hello world</title>"); out.println("</head>"); out.println("<body bgcolor="+co+">"); out.println("<h1>hello</h1>"); out.println("request method is "+request.getMethod()); out.println("uri is "+request.getRequestURI()); out.println("protocol is "+request.getProtocol()); out.println("remote addr is"+request.getRemoteAddr()); out.println("</body>"); out.println("</html>"); } } 10.b(html) <html <body>
  • 7. <form action="http://localhost:8080/servlet/pro2b" method="GET"> <h1> welcome </h1> <select name="cn"> <option value="indigo">indigo</option> <option value="green">green</option> <option value="blue" selected="selected">blue</option> </select> <input type="submit" value="submit"> </form> </body> </html> 11(jsp) import java.io.*; import javax.servlet.*; import java.util.*; import javax.servlet.http.*; public class prog11 extends HttpServlet{ public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException { res.setContentType("text/html"); PrintWriter out=res.getWriter(); String str=new String(); Calendar cl=Calendar.getInstance(); int hr=cl.get(Calendar.HOUR_OF_DAY); if(hr>=0 && hr<12) { out.println("Good Morning....."); } if(hr>=12 && hr<16) { out.println("Good Afternoon..."); } if(hr>=16 && hr<20) { out.println("Good Evening..."); } if(hr>=20){ out.println("GO to Sleep....."); }}} 12(jsp) import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class newcookies extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { PrintWriter out=res.getWriter(); Cookie[] cookies_list = req.getCookies(); String name=req.getParameter("txtname"); String val=req.getParameter("txtval"); res.setContentType("text/html"); out.println("<html>"); if(name==null) { if(cookies_list!=null) {
  • 8. out.println("Cookies Stored!!!"); int i; for(i=0;i<cookies_list.length;i++) out.println(cookies_list[i].getName() + ":" + cookies_list[i].getValue() + "<br>"); } out.println("<form action=http://localhost:8080/servlet/newcookies method=get>"); out.println("Enter the name ... <input name=txtname>"); out.println("Enter the value ... <input name=txtval>"); out.println("<input type=submit value=submit>"); out.println("</form> </html>"); } else if(name!=null) { Cookie cookName=new Cookie(name,val); res.addCookie(cookName); out.println("Cookies submitted successfully!!!"); } } } 13(jsp) import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class prog13 extends HttpServlet{ public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException { res.setContentType("text/html"); PrintWriter out=res.getWriter(); HttpSession hs=req.getSession(true); out.println("Session ID:"+hs.getId()); Date d1=new Date(hs.getCreationTime()); out.println("<br>Creation Time:"+d1); Date d2=new Date(hs.getLastAccessedTime()); out.println("<br>Last Access Time:"+d2); } } 14(jsp) import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class pro14 extends HttpServlet { public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException { response.setContentType("text/html"); PrintWriter out=response.getWriter(); out.println("<html>"); out.println("<head>"); out.println("<title>hello world</title>"); out.println("</head>"); out.println("<body>"); out.println("<h1>hello</h1>");
  • 9. out.println("request method is "+request.getMethod()); out.println("uri is "+request.getRequestURI()); out.println("protocol is "+request.getProtocol()); out.println("remote addr is"+request.getRemoteAddr()); out.println("</body>"); out.println("</html>"); } } 15(jsp) /* 15. Program to accept username and address and display them in a web page by passing parameters. */ import java.lang.*; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class prg15 extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException { PrintWriter out=res.getWriter(); out.println("<html>"); out.println("<head><title>Program 15 </title></head>"); out.println("<body>"); out.println("<h1>User Information</h1>"); out.println("<br><hr><br>"); out.println("<form method=post action=/servlet/prg15"); out.println("Dear User.<br>"); out.println("Please Enter the following Information.<br><br>"); out.println("UserName: <input type=text name=username value=""><br><br>"); out.println("Address: <input type=text name=address value=""><br><br>"); out.println("<input type=submit value=Submit><input type=reset value=Clear>"); out.println("</form>"); out.println("</body></html>"); } public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException
  • 10. { PrintWriter out=res.getWriter(); String username=req.getParameter("username"); String address=req.getParameter("address"); out.println("<html>"); out.println("<head><title>Program 15 </title></head>"); out.println("<body>"); out.println("<h1>User Information</h1>"); out.println("<br><hr><br>"); out.println("Dear User.<br>"); out.println("Your Information.<br><br>"); out.println("UserName: "+username+"<br>"); out.println("Address :"+address+"<br>"); out.println("<br><center><a href=/servlet/prg15>Back</a></center>"); out.println("</body>"); out.println("</html>"); } }