SlideShare a Scribd company logo
PHP vs. JSP
Hello World - JSP <HTML> <HEAD> <TITLE>JSP -- Hello World!</TITLE> </HEAD> <BODY> &nbsp; <% out.println(&quot; Hello World&quot;); %>   ! </BODY> </HTML>
Hello World - PHP <HTML> <HEAD> <TITLE>PHP – Hello World!</TITLE> </HEAD> <BODY> <CENTER> <FONT COLOR=RED SIZE=5> &nbsp; <?php echo &quot;Hello world!&quot;;?>   ! </FONT> </CENTER> </BODY> </HTML>
JSP – Print date as dd/MM/yyyy <HTML> <HEAD> <TITLE>JSP -- Hello World!</TITLE> </HEAD> <BODY> <% java.util.Calendar cal = java.util.Calendar.getInstance(); out.println( new  SimpleDateFormat(“dd/MM/yyyy).format (cal.getTime()‏) );  %>   </BODY> </HTML>
PHP – Print Date as dd/MM/yyyy <HTML> <HEAD> <TITLE>PHP – Hello World!</TITLE> </HEAD> <BODY> <CENTER> <FONT COLOR=RED SIZE=5> &nbsp; <?php echo date(“d/m/Y”)?>   ! </FONT> </CENTER> </BODY> </HTML>
JSP – Handling Forms The form: <html> <body> <form action=&quot;welcome.jsp&quot; method=&quot;post&quot;> Name: <input type=&quot;text&quot; name=&quot;name&quot; /> Age: <input type=&quot;text&quot; name=&quot;age&quot; /> <input type=&quot;submit&quot; /> </form> </body> </html> Handler: <html> <body> Welcome  <%request.getParameter(&quot;name”)%> .<br /> You are  <%request.getParameter(&quot;age”)%>  years old. </body> </html>
PHP – Handling Forms The form: <html> <body> <form action=&quot;welcome.php&quot; method=&quot;post&quot;> Name: <input type=&quot;text&quot; name=&quot;name&quot; /> Age: <input type=&quot;text&quot; name=&quot;age&quot; /> <input type=&quot;submit&quot; /> </form> </body> </html> Handler: <html> <body> Welcome  <?php echo $_REQUEST[&quot;name&quot;]; ?> .<br /> You are  <?php echo $_REQUEST[&quot;age&quot;]; ?>  years old. </body> </html>
JSP - Session <html> <body>   <% //Get current session or create a new session HtppSession session = request.getSession(true);  //Add information to the session session.setAttribute(“name”, “Pramati”); //Print the information out.println(session.getAttribute(“name”); %> </body> </html>
PHP - Session //Getting or starting a new session <?php session_start(); ?> <html> <body>   <?php //Add information to the session $_SESSION['name']= “Pramati”; //Print the information echo $_SESSION['name'];   ?> </body> </html>
JSP – Mail Form <HTML> <FORM METHOD=POST ACTION=”mailform.jsp”> SMTP SERVER: <INPUT TYPE=&quot;text&quot; NAME=&quot;p_smtpServer&quot; SIZE=60 VALUE=&quot;<%= l_svr!=null ? l_svr : &quot;&quot; %>&quot; > TO: <INPUT TYPE=TEXT SIZE=60 MAXLENGTH=200 NAME=&quot;p_to&quot;> FROM: <INPUT TYPE=TEXT SIZE=60 MAXLENGTH=200 NAME=&quot;p_bcc&quot;> SUBJECT: <INPUT TYPE=TEXT SIZE=60 MAXLENGTH=100 NAME=&quot;p_subject&quot;> MESSAGE:<br>   <TEXTAREA NAME=&quot;p_message&quot; ROWS=10 COLS=66 SIZE=2000 WRAP=HARD>   </TEXTAREA>   <INPUT TYPE='SUBMIT'>   </FORM> </HTML>
JSP – Mail Sender <html>  <jsp:useBean id=&quot;sendMail&quot; class=&quot;SendMailBean&quot; scope=&quot;page&quot; /> <% String l_from  =  request.getParameter (&quot;p_from&quot;);   String l_to  =  request.getParameter (&quot;p_to&quot;);   String l_cc  =  request.getParameter (&quot;p_cc&quot;);   String l_subject =  request.getParameter (&quot;p_subject&quot;);   String l_message =  request.getParameter (&quot;p_message&quot;);   %>   <%= sendMail.send(l_from, l_to, l_cc, l_subject, l_message) %> </html>
JSP – Mail sender bean – Page 1 import javax.mail.*;  //JavaMail packages import javax.mail.internet.*; //JavaMail Internet packages import java.util.*;  //Java Util packages public class SendMailBean { public String send(String p_from, String p_to, String p_subject, String p_message, String p_smtpServer) { // Gets the System properties Properties l_props = System.getProperties(); // Puts the SMTP server name to properties object   l_props.put(&quot;mail.smtp.host&quot;,p_smtpServer); // Get the default Session using Properties Object Session l_session = Session.getDefaultInstance(l_props, null); l_session.setDebug(true); // Enable the debug mode
JSP – Mail sender bean – Page 2 try {   MimeMessage l_msg = new MimeMessage(l_session); // Create a New message   l_msg.setFrom(new InternetAddress(p_from)); // Set the From address   l_msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(p_to, false));   l_msg.setSubject(p_subject); // Sets the Subject   MimeBodyPart l_mbp = new MimeBodyPart();   l_mbp.setText(p_message);   // Create the Multipart and its parts to it   Multipart l_mp = new MimeMultipart();   l_mp.addBodyPart(l_mbp);   // Add the Multipart to the message   l_msg.setContent(l_mp);   // Set the Date: header   l_msg.setSentDate(new Date());
JSP – Mail sender bean – Page 3   // Send the message   Transport.send(l_msg);   // If here, then message is successfully sent.   // Display Success message   return “Mail sent”; } catch (Exception e) { return “Mail failed”; }
PHP – Mail form <HTML> <FORM METHOD=POST ACTION=”mailform.php”> TO: <INPUT TYPE=TEXT SIZE=60 MAXLENGTH=200 NAME=&quot;p_to&quot;> SUBJECT: <INPUT TYPE=TEXT SIZE=60 MAXLENGTH=100 NAME=&quot;p_subject&quot;> MESSAGE:<br>   <TEXTAREA NAME=&quot;p_message&quot; ROWS=10 COLS=66 SIZE=2000 WRAP=HARD>   </TEXTAREA>   <INPUT TYPE='SUBMIT'>   </FORM> </HTML>
PHP – Mail Sender <?php //send email $email = $_REQUEST['email'] ;  $subject = $_REQUEST['subject'] ; $message = $_REQUEST['message'] ; mail( &quot;someone@example.com&quot;, &quot;Subject: $subject&quot;,  $message, &quot;From: $email&quot; ); echo &quot;Thank you for using our mail form&quot;; ?>
JSP – File Upload Form Note: No in-built support. Should rely on libraries. This example uses Apache's commons-upload lib. <HTML> <HEAD> <META HTTP-EQUIV=&quot;Content-Type&quot; CONTENT=&quot;text/html; charset=windows-1252&quot;/> <TITLE>File Upload Page</TITLE> </HEAD> <BODY>Upload Files <FORM name=&quot;filesForm&quot; action=&quot;ProcessFileUpload.jsp&quot;   method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;> File 1:<input type=&quot;file&quot; name=&quot;file1&quot;/><br/>   <input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Upload File&quot;/> </FORM> </BODY> </HTML>
JSP – File Upload <html> <body> <% if(ServletFileUpload.isMultipartContent(request))‏ { FileItemFactory factory = new DiskFileItemFactory();   ServletFileUpload upload = new ServletFileUpload(factory);   List items = upload.parseRequest(request);   Iterator itemsIter = items.getIterator();   if(iter.hasNext())‏   { File uploadedFile = new File(item.getName());  item.write(uploadedFile);    } } %> </body> </html>
PHP File Upload Form <HTML> <HEAD> <META HTTP-EQUIV=&quot;Content-Type&quot; CONTENT=&quot;text/html; charset=windows-1252&quot;/> <TITLE>File Upload Page</TITLE> </HEAD> <BODY>Upload Files <FORM name=&quot;filesForm&quot; action=&quot;ProcessFileUpload.php&quot;   method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;>   File 1:<input type=&quot;file&quot; name=&quot;file1&quot;/><br/>   <input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Upload File&quot;/> </FORM> </BODY> </HTML>
PHP – File Upload <?php if ($_FILES[&quot;file&quot;][&quot;error&quot;] > 0)‏ { echo &quot;Return Code: &quot; . $_FILES[&quot;file&quot;][&quot;error&quot;] . &quot;<br />&quot;; } else { move_uploaded_file($_FILES[&quot;file&quot;][&quot;tmp_name&quot;],  &quot;upload/&quot; . $_FILES[&quot;file&quot;][&quot;name&quot;]); echo &quot;Stored in: &quot; . &quot;upload/&quot; . $_FILES[&quot;file&quot;][&quot;name&quot;]; } } ?>
JSP and Database - I <%@ page import=&quot;java.sql.*&quot; %> <HTML> <HEAD> <TITLE>Employee List</TITLE> </HEAD> <BODY> <TABLE BORDER=1 width=&quot;75%&quot;> <TR> <TH>Last Name</TH><TH>First Name</TH> </TR> <% //Connection conn = null; java.sql.Connection conn= null; Statement st = null; ResultSet rs = null;
JSP and Database - II try { // Class.forName(&quot;com.mysql.jdbc.Driver&quot;).newInstance(); Class.forName(&quot;org.gjt.mm.mysql.Driver&quot;).newInstance(); conn = DriverManager.getConnection( &quot;jdbc:mysql://localhost/jsp?user=xxx&password=xxx&quot;); st = conn.createStatement(); rs = st.executeQuery(&quot;select * from employees&quot;); while(rs.next()) { %> <TR><TD><%= rs.getString(&quot;lname_txt&quot;) %></TD> <TD><%= rs.getString(&quot;fname_txt&quot;) %></TD></TR> <% } %> </TABLE>
JSP and Database - III <% } catch (Exception ex) { ex.printStackTrace(); %> </TABLE> Ooops, something bad happened: <% } finally { if (rs != null) rs.close(); if (st != null) st.close(); if (conn != null) conn.close(); } %> </BODY> </HTML>
PHP and Database - I <? $username=&quot;username&quot;; $password=&quot;password&quot;; $database=&quot;your_database&quot;; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( &quot;Unable to select database&quot;); $query=&quot;SELECT * FROM contacts&quot;; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close();
PHP and Database - II echo &quot;<b><center>Database Output</center></b><br><br>&quot;; $i=0; while ($i < $num) { $first=mysql_result($result,$i,&quot;first&quot;); $last=mysql_result($result,$i,&quot;last&quot;); $phone=mysql_result($result,$i,&quot;phone&quot;); $mobile=mysql_result($result,$i,&quot;mobile&quot;); $fax=mysql_result($result,$i,&quot;fax&quot;); $email=mysql_result($result,$i,&quot;email&quot;); $web=mysql_result($result,$i,&quot;web&quot;); echo &quot;<b>$first $last</b><br>Phone: $phone<br>Mobile: $mobile<br>Fax: $fax<br>E-mail:  $email<br>Web: $web<br><hr><br>&quot;; $i++; } ?>

More Related Content

What's hot

開放源碼電子書與EPUB幕後排版
開放源碼電子書與EPUB幕後排版開放源碼電子書與EPUB幕後排版
開放源碼電子書與EPUB幕後排版Kyle Lin
 
Computer Networks: An Introduction
Computer Networks: An IntroductionComputer Networks: An Introduction
Computer Networks: An Introductionsanand0
 
Http header的方方面面
Http header的方方面面Http header的方方面面
Http header的方方面面Tony Deng
 
Advanced SEO for Web Developers
Advanced SEO for Web DevelopersAdvanced SEO for Web Developers
Advanced SEO for Web DevelopersNathan Buggia
 
Making sense of users' Web activities
Making sense of users' Web activitiesMaking sense of users' Web activities
Making sense of users' Web activitiesMathieu d'Aquin
 
Sphinx 1.1 i18n 機能紹介
Sphinx 1.1 i18n 機能紹介Sphinx 1.1 i18n 機能紹介
Sphinx 1.1 i18n 機能紹介Ian Lewis
 
LinkedIn Platform at LeWeb 2010
LinkedIn Platform at LeWeb 2010LinkedIn Platform at LeWeb 2010
LinkedIn Platform at LeWeb 2010Adam Trachtenberg
 
.htaccess for SEOs - A presentation by Roxana Stingu
.htaccess for SEOs - A presentation by Roxana Stingu.htaccess for SEOs - A presentation by Roxana Stingu
.htaccess for SEOs - A presentation by Roxana StinguRoxana Stingu
 

What's hot (12)

Phpwebdevelping
PhpwebdevelpingPhpwebdevelping
Phpwebdevelping
 
開放源碼電子書與EPUB幕後排版
開放源碼電子書與EPUB幕後排版開放源碼電子書與EPUB幕後排版
開放源碼電子書與EPUB幕後排版
 
Computer Networks: An Introduction
Computer Networks: An IntroductionComputer Networks: An Introduction
Computer Networks: An Introduction
 
Http header的方方面面
Http header的方方面面Http header的方方面面
Http header的方方面面
 
Advanced SEO for Web Developers
Advanced SEO for Web DevelopersAdvanced SEO for Web Developers
Advanced SEO for Web Developers
 
Lect_html1
Lect_html1Lect_html1
Lect_html1
 
Making sense of users' Web activities
Making sense of users' Web activitiesMaking sense of users' Web activities
Making sense of users' Web activities
 
Sphinx 1.1 i18n 機能紹介
Sphinx 1.1 i18n 機能紹介Sphinx 1.1 i18n 機能紹介
Sphinx 1.1 i18n 機能紹介
 
LinkedIn Platform at LeWeb 2010
LinkedIn Platform at LeWeb 2010LinkedIn Platform at LeWeb 2010
LinkedIn Platform at LeWeb 2010
 
Introduction to python scrapping
Introduction to python scrappingIntroduction to python scrapping
Introduction to python scrapping
 
PHP 5 Sucks. PHP 5 Rocks.
PHP 5 Sucks. PHP 5 Rocks.PHP 5 Sucks. PHP 5 Rocks.
PHP 5 Sucks. PHP 5 Rocks.
 
.htaccess for SEOs - A presentation by Roxana Stingu
.htaccess for SEOs - A presentation by Roxana Stingu.htaccess for SEOs - A presentation by Roxana Stingu
.htaccess for SEOs - A presentation by Roxana Stingu
 

Viewers also liked

Viewers also liked (20)

Sàlix i els sentits
Sàlix i els sentitsSàlix i els sentits
Sàlix i els sentits
 
apostila yorubá
apostila yorubáapostila yorubá
apostila yorubá
 
Roupas Jumps
Roupas JumpsRoupas Jumps
Roupas Jumps
 
Prometete
PrometetePrometete
Prometete
 
diir-press-kit
diir-press-kitdiir-press-kit
diir-press-kit
 
Recordes?
Recordes?Recordes?
Recordes?
 
PresentacióN Tema IX
PresentacióN Tema  IXPresentacióN Tema  IX
PresentacióN Tema IX
 
misión y visión
misión y visiónmisión y visión
misión y visión
 
Artigo como escolher seu coach
Artigo como escolher seu coachArtigo como escolher seu coach
Artigo como escolher seu coach
 
Novo Plano da BBOM
Novo Plano da BBOMNovo Plano da BBOM
Novo Plano da BBOM
 
Missa mãe
Missa mãeMissa mãe
Missa mãe
 
Feliz navidad
Feliz navidadFeliz navidad
Feliz navidad
 
Bienvenido a su clase de historia de honduras
Bienvenido a su clase de historia de hondurasBienvenido a su clase de historia de honduras
Bienvenido a su clase de historia de honduras
 
IT NEWS
IT NEWSIT NEWS
IT NEWS
 
L´Aigua
L´AiguaL´Aigua
L´Aigua
 
CAN 2008 - quelques images
CAN 2008 - quelques imagesCAN 2008 - quelques images
CAN 2008 - quelques images
 
webdynpro Application attach in Menu
webdynpro Application attach in Menuwebdynpro Application attach in Menu
webdynpro Application attach in Menu
 
Trabalho de geografia (1)
Trabalho de geografia (1)Trabalho de geografia (1)
Trabalho de geografia (1)
 
Resumosocio
ResumosocioResumosocio
Resumosocio
 
Pagina 1
Pagina 1Pagina 1
Pagina 1
 

Similar to Phpvsjsp

PHP Presentation
PHP PresentationPHP Presentation
PHP PresentationNikhil Jain
 
YL Intro html
YL Intro htmlYL Intro html
YL Intro htmldilom1986
 
Php Crash Course
Php Crash CoursePhp Crash Course
Php Crash Coursemussawir20
 
KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7phuphax
 
Introduction To Lamp
Introduction To LampIntroduction To Lamp
Introduction To LampAmzad Hossain
 
Php Calling Operators
Php Calling OperatorsPhp Calling Operators
Php Calling Operatorsmussawir20
 
The Basics Of Page Creation
The Basics Of Page CreationThe Basics Of Page Creation
The Basics Of Page CreationWildan Maulana
 
Java Script
Java ScriptJava Script
Java Scriptsiddaram
 
PHP Presentation
PHP PresentationPHP Presentation
PHP PresentationAnkush Jain
 
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google InfrastructureLiving in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google InfrastructurePamela Fox
 
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google InfrastructureLiving in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructureguest517f2f
 
Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)Michiel Rook
 
PHPTAL introduction
PHPTAL introductionPHPTAL introduction
PHPTAL introduction'"">
 
Php Basic Security
Php Basic SecurityPhp Basic Security
Php Basic Securitymussawir20
 
Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP yucefmerhi
 

Similar to Phpvsjsp (20)

Lecture3
Lecture3Lecture3
Lecture3
 
PHP Presentation
PHP PresentationPHP Presentation
PHP Presentation
 
Php 3 1
Php 3 1Php 3 1
Php 3 1
 
YL Intro html
YL Intro htmlYL Intro html
YL Intro html
 
Php
PhpPhp
Php
 
Php Crash Course
Php Crash CoursePhp Crash Course
Php Crash Course
 
KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7
 
Introduction To Lamp
Introduction To LampIntroduction To Lamp
Introduction To Lamp
 
Php Calling Operators
Php Calling OperatorsPhp Calling Operators
Php Calling Operators
 
The Basics Of Page Creation
The Basics Of Page CreationThe Basics Of Page Creation
The Basics Of Page Creation
 
Java Script
Java ScriptJava Script
Java Script
 
Web development
Web developmentWeb development
Web development
 
PHP Presentation
PHP PresentationPHP Presentation
PHP Presentation
 
Intro Html
Intro HtmlIntro Html
Intro Html
 
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google InfrastructureLiving in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
 
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google InfrastructureLiving in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
 
Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)
 
PHPTAL introduction
PHPTAL introductionPHPTAL introduction
PHPTAL introduction
 
Php Basic Security
Php Basic SecurityPhp Basic Security
Php Basic Security
 
Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP
 

Recently uploaded

Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Product School
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyJohn Staveley
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCzechDreamin
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...Product School
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...Elena Simperl
 
Introduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG EvaluationIntroduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG EvaluationZilliz
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...Product School
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeCzechDreamin
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2DianaGray10
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomCzechDreamin
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...CzechDreamin
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutesconfluent
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Product School
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesThousandEyes
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxAbida Shariff
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIES VE
 

Recently uploaded (20)

Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Introduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG EvaluationIntroduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG Evaluation
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 

Phpvsjsp

  • 2. Hello World - JSP <HTML> <HEAD> <TITLE>JSP -- Hello World!</TITLE> </HEAD> <BODY> &nbsp; <% out.println(&quot; Hello World&quot;); %> ! </BODY> </HTML>
  • 3. Hello World - PHP <HTML> <HEAD> <TITLE>PHP – Hello World!</TITLE> </HEAD> <BODY> <CENTER> <FONT COLOR=RED SIZE=5> &nbsp; <?php echo &quot;Hello world!&quot;;?> ! </FONT> </CENTER> </BODY> </HTML>
  • 4. JSP – Print date as dd/MM/yyyy <HTML> <HEAD> <TITLE>JSP -- Hello World!</TITLE> </HEAD> <BODY> <% java.util.Calendar cal = java.util.Calendar.getInstance(); out.println( new SimpleDateFormat(“dd/MM/yyyy).format (cal.getTime()‏) ); %> </BODY> </HTML>
  • 5. PHP – Print Date as dd/MM/yyyy <HTML> <HEAD> <TITLE>PHP – Hello World!</TITLE> </HEAD> <BODY> <CENTER> <FONT COLOR=RED SIZE=5> &nbsp; <?php echo date(“d/m/Y”)?> ! </FONT> </CENTER> </BODY> </HTML>
  • 6. JSP – Handling Forms The form: <html> <body> <form action=&quot;welcome.jsp&quot; method=&quot;post&quot;> Name: <input type=&quot;text&quot; name=&quot;name&quot; /> Age: <input type=&quot;text&quot; name=&quot;age&quot; /> <input type=&quot;submit&quot; /> </form> </body> </html> Handler: <html> <body> Welcome <%request.getParameter(&quot;name”)%> .<br /> You are <%request.getParameter(&quot;age”)%> years old. </body> </html>
  • 7. PHP – Handling Forms The form: <html> <body> <form action=&quot;welcome.php&quot; method=&quot;post&quot;> Name: <input type=&quot;text&quot; name=&quot;name&quot; /> Age: <input type=&quot;text&quot; name=&quot;age&quot; /> <input type=&quot;submit&quot; /> </form> </body> </html> Handler: <html> <body> Welcome <?php echo $_REQUEST[&quot;name&quot;]; ?> .<br /> You are <?php echo $_REQUEST[&quot;age&quot;]; ?> years old. </body> </html>
  • 8. JSP - Session <html> <body> <% //Get current session or create a new session HtppSession session = request.getSession(true); //Add information to the session session.setAttribute(“name”, “Pramati”); //Print the information out.println(session.getAttribute(“name”); %> </body> </html>
  • 9. PHP - Session //Getting or starting a new session <?php session_start(); ?> <html> <body> <?php //Add information to the session $_SESSION['name']= “Pramati”; //Print the information echo $_SESSION['name']; ?> </body> </html>
  • 10. JSP – Mail Form <HTML> <FORM METHOD=POST ACTION=”mailform.jsp”> SMTP SERVER: <INPUT TYPE=&quot;text&quot; NAME=&quot;p_smtpServer&quot; SIZE=60 VALUE=&quot;<%= l_svr!=null ? l_svr : &quot;&quot; %>&quot; > TO: <INPUT TYPE=TEXT SIZE=60 MAXLENGTH=200 NAME=&quot;p_to&quot;> FROM: <INPUT TYPE=TEXT SIZE=60 MAXLENGTH=200 NAME=&quot;p_bcc&quot;> SUBJECT: <INPUT TYPE=TEXT SIZE=60 MAXLENGTH=100 NAME=&quot;p_subject&quot;> MESSAGE:<br> <TEXTAREA NAME=&quot;p_message&quot; ROWS=10 COLS=66 SIZE=2000 WRAP=HARD> </TEXTAREA> <INPUT TYPE='SUBMIT'>   </FORM> </HTML>
  • 11. JSP – Mail Sender <html> <jsp:useBean id=&quot;sendMail&quot; class=&quot;SendMailBean&quot; scope=&quot;page&quot; /> <% String l_from = request.getParameter (&quot;p_from&quot;); String l_to = request.getParameter (&quot;p_to&quot;); String l_cc = request.getParameter (&quot;p_cc&quot;); String l_subject = request.getParameter (&quot;p_subject&quot;); String l_message = request.getParameter (&quot;p_message&quot;); %> <%= sendMail.send(l_from, l_to, l_cc, l_subject, l_message) %> </html>
  • 12. JSP – Mail sender bean – Page 1 import javax.mail.*; //JavaMail packages import javax.mail.internet.*; //JavaMail Internet packages import java.util.*; //Java Util packages public class SendMailBean { public String send(String p_from, String p_to, String p_subject, String p_message, String p_smtpServer) { // Gets the System properties Properties l_props = System.getProperties(); // Puts the SMTP server name to properties object l_props.put(&quot;mail.smtp.host&quot;,p_smtpServer); // Get the default Session using Properties Object Session l_session = Session.getDefaultInstance(l_props, null); l_session.setDebug(true); // Enable the debug mode
  • 13. JSP – Mail sender bean – Page 2 try { MimeMessage l_msg = new MimeMessage(l_session); // Create a New message l_msg.setFrom(new InternetAddress(p_from)); // Set the From address l_msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(p_to, false)); l_msg.setSubject(p_subject); // Sets the Subject MimeBodyPart l_mbp = new MimeBodyPart(); l_mbp.setText(p_message); // Create the Multipart and its parts to it Multipart l_mp = new MimeMultipart(); l_mp.addBodyPart(l_mbp); // Add the Multipart to the message l_msg.setContent(l_mp); // Set the Date: header l_msg.setSentDate(new Date());
  • 14. JSP – Mail sender bean – Page 3 // Send the message Transport.send(l_msg); // If here, then message is successfully sent. // Display Success message return “Mail sent”; } catch (Exception e) { return “Mail failed”; }
  • 15. PHP – Mail form <HTML> <FORM METHOD=POST ACTION=”mailform.php”> TO: <INPUT TYPE=TEXT SIZE=60 MAXLENGTH=200 NAME=&quot;p_to&quot;> SUBJECT: <INPUT TYPE=TEXT SIZE=60 MAXLENGTH=100 NAME=&quot;p_subject&quot;> MESSAGE:<br> <TEXTAREA NAME=&quot;p_message&quot; ROWS=10 COLS=66 SIZE=2000 WRAP=HARD> </TEXTAREA> <INPUT TYPE='SUBMIT'>   </FORM> </HTML>
  • 16. PHP – Mail Sender <?php //send email $email = $_REQUEST['email'] ; $subject = $_REQUEST['subject'] ; $message = $_REQUEST['message'] ; mail( &quot;someone@example.com&quot;, &quot;Subject: $subject&quot;, $message, &quot;From: $email&quot; ); echo &quot;Thank you for using our mail form&quot;; ?>
  • 17. JSP – File Upload Form Note: No in-built support. Should rely on libraries. This example uses Apache's commons-upload lib. <HTML> <HEAD> <META HTTP-EQUIV=&quot;Content-Type&quot; CONTENT=&quot;text/html; charset=windows-1252&quot;/> <TITLE>File Upload Page</TITLE> </HEAD> <BODY>Upload Files <FORM name=&quot;filesForm&quot; action=&quot;ProcessFileUpload.jsp&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;> File 1:<input type=&quot;file&quot; name=&quot;file1&quot;/><br/> <input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Upload File&quot;/> </FORM> </BODY> </HTML>
  • 18. JSP – File Upload <html> <body> <% if(ServletFileUpload.isMultipartContent(request))‏ { FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); List items = upload.parseRequest(request); Iterator itemsIter = items.getIterator(); if(iter.hasNext())‏ { File uploadedFile = new File(item.getName()); item.write(uploadedFile); } } %> </body> </html>
  • 19. PHP File Upload Form <HTML> <HEAD> <META HTTP-EQUIV=&quot;Content-Type&quot; CONTENT=&quot;text/html; charset=windows-1252&quot;/> <TITLE>File Upload Page</TITLE> </HEAD> <BODY>Upload Files <FORM name=&quot;filesForm&quot; action=&quot;ProcessFileUpload.php&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;> File 1:<input type=&quot;file&quot; name=&quot;file1&quot;/><br/> <input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Upload File&quot;/> </FORM> </BODY> </HTML>
  • 20. PHP – File Upload <?php if ($_FILES[&quot;file&quot;][&quot;error&quot;] > 0)‏ { echo &quot;Return Code: &quot; . $_FILES[&quot;file&quot;][&quot;error&quot;] . &quot;<br />&quot;; } else { move_uploaded_file($_FILES[&quot;file&quot;][&quot;tmp_name&quot;], &quot;upload/&quot; . $_FILES[&quot;file&quot;][&quot;name&quot;]); echo &quot;Stored in: &quot; . &quot;upload/&quot; . $_FILES[&quot;file&quot;][&quot;name&quot;]; } } ?>
  • 21. JSP and Database - I <%@ page import=&quot;java.sql.*&quot; %> <HTML> <HEAD> <TITLE>Employee List</TITLE> </HEAD> <BODY> <TABLE BORDER=1 width=&quot;75%&quot;> <TR> <TH>Last Name</TH><TH>First Name</TH> </TR> <% //Connection conn = null; java.sql.Connection conn= null; Statement st = null; ResultSet rs = null;
  • 22. JSP and Database - II try { // Class.forName(&quot;com.mysql.jdbc.Driver&quot;).newInstance(); Class.forName(&quot;org.gjt.mm.mysql.Driver&quot;).newInstance(); conn = DriverManager.getConnection( &quot;jdbc:mysql://localhost/jsp?user=xxx&password=xxx&quot;); st = conn.createStatement(); rs = st.executeQuery(&quot;select * from employees&quot;); while(rs.next()) { %> <TR><TD><%= rs.getString(&quot;lname_txt&quot;) %></TD> <TD><%= rs.getString(&quot;fname_txt&quot;) %></TD></TR> <% } %> </TABLE>
  • 23. JSP and Database - III <% } catch (Exception ex) { ex.printStackTrace(); %> </TABLE> Ooops, something bad happened: <% } finally { if (rs != null) rs.close(); if (st != null) st.close(); if (conn != null) conn.close(); } %> </BODY> </HTML>
  • 24. PHP and Database - I <? $username=&quot;username&quot;; $password=&quot;password&quot;; $database=&quot;your_database&quot;; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( &quot;Unable to select database&quot;); $query=&quot;SELECT * FROM contacts&quot;; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close();
  • 25. PHP and Database - II echo &quot;<b><center>Database Output</center></b><br><br>&quot;; $i=0; while ($i < $num) { $first=mysql_result($result,$i,&quot;first&quot;); $last=mysql_result($result,$i,&quot;last&quot;); $phone=mysql_result($result,$i,&quot;phone&quot;); $mobile=mysql_result($result,$i,&quot;mobile&quot;); $fax=mysql_result($result,$i,&quot;fax&quot;); $email=mysql_result($result,$i,&quot;email&quot;); $web=mysql_result($result,$i,&quot;web&quot;); echo &quot;<b>$first $last</b><br>Phone: $phone<br>Mobile: $mobile<br>Fax: $fax<br>E-mail: $email<br>Web: $web<br><hr><br>&quot;; $i++; } ?>