WebTech UNIT - 3 Notes
WebTech UNIT - 3 Notes
process requests, access databases, and return responses to users.
dy
Common Server-Side Scripting Languages:
● HP– Open-source, widely used for web applications.
P
● CGI (Common Gateway Interface)– Used to execute scriptson a web server.
tu
● JSP (Java Server Pages)– Uses Java to create dynamicweb pages.
● ASP.NET– Developed by Microsoft for web applications.
● Node.js– Uses JavaScript for backend development.
yS
2. PHP Development
HP (Hypertext Preprocessor) is a popular open-source server-side scripting language used
P
for developing dynamic websites and applications.
da
$.
● Variables begin with
// Single-lineand
● Comments: /* Multi-line */
.
Example:
<?php
echo "Hello, World!";
?>
$,followed by a name.
Variables store data and start with
name = "John";
$
$age = 25;
V
● ariables are case-sensitive.
● They do not require explicit declaration.
● Supported data types include strings, integers, floats, arrays, objects, etc.
● String: A sequence of characters (
"Hello"
)
dy
● Integer: Whole numbers (
123
)
● Float: Decimal numbers (
3.14
)
trueor
● Boolean: false
A
● rray: Collection of values (
$colors = array("Red",
"Green");
)
tu
● Object: Instance of a class
Example:
da
var = 10.5;
$
echo gettype($var); // Output: double
var_dump($var); // Output: float(10.5)
ne
●
is_int($var)
: Checks if it is an integer.
O
●
is_string($var)
: Checks if it is a string.
●
is_array($var)
: Checks if it is an array.
Example:
var = "Hello";
$
if (is_string($var)) {
echo "Variable is a string.";
}
OnedayStudy WebTechVisit
<html>
dy
<body>
<h1>Hello, JSP!</h1>
</body>
</html>
Example:
<%!
int num = 10;
%>
ne
<%
num += 5;
%>
The value is: <%= num %>
O
%
<
session.setAttribute("username", "John");
%>
Welcome, <%= session.getAttribute("username") %>!
OnedayStudy WebTechVisit
%
<
response.sendRedirect("home.jsp");
%>
Servlets are Java programs that run on a web server and handle HTTP requests.
dy
4.1 Servlet Lifecycle
1. Initialization(
i
nit()
) – Called once when servletis loaded.
2. Request Handling(
service()
) – Processes client requests.
tu
3. Destruction(
d
estroy()
) – Cleans up resources beforetermination.
}
}
. C
1 javac HelloServlet.java
ompile the servlet:
2. Deploy it in a web server (e.g., Apache Tomcat).
3. Configureweb.xmlfor mapping.
web.xml
Example :
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>HelloServlet</servlet-class>
</servlet>
OnedayStudy WebTechVisit
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
out.println("Welcome, " + session.getAttribute("username"));
dy
4.5 Redirecting in Servlets
response.sendRedirect("home.jsp");
tu
yS
Conclusion
P
● HPis widely used for server-side development dueto its simplicity.
● JSP & Servletsprovide Java-based solutions for dynamicweb applications.
da
his unit provides a foundation for building dynamic, interactive, and secure web
T
applications using PHP and Java-based technologies.
ne
SP.NET—> OPEN
A
SOFTWARE ENGINEERING —>OPEN
OBJECT ORIENTED PROGRAMMING USING JAVA —->OPEN
ONEDAYSTUDY —->OPEN