0% found this document useful (0 votes)
25 views

3. ASP

Uploaded by

ff8961977
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

3. ASP

Uploaded by

ff8961977
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Built in Objects in ASP

In classic ASP (Active Server Pages), there are several built-in objects that
provide functionality for dynamic web page generation and interaction with the server.
Some of the key built-in objects in classic ASP include:
1.Request: This object is used to retrieve values that the client browser submits to the
server during an HTTP request, such as form data, query string parameters, and cookie
values.
2.Response: The Response object is used to send output to the client browser, including
HTML, text, and binary data. It also provides methods for managing HTTP headers and
redirecting the user to another page.
3.Server: The Server object provides access to various server-related functionalities, such
as reading and writing files on the server, executing commands, and managing
application-level variables.
4.Session: The Session object enables you to store and retrieve user-specific data across
multiple requests. It allows you to create session variables that persist for the duration of a
user's visit to the website.
1.Application: The Application object allows you to store and
share data across all users of a web application. It is typically
used for storing global variables and maintaining application
state.
2.Server.MapPath: This method converts a virtual path (a path
relative to the web server) into a physical path (a path on the
server's file system). It is often used to access files or resources
within the web application's directory structure.
3.Server.CreateObject: This function is used to create
instances of COM (Component Object Model) objects, which can
be used to access external components or services.
4.ADO (ActiveX Data Objects): A set of objects used for
accessing and manipulating databases in classic ASP. ADO
provides a way to connect to databases, execute SQL queries,
and retrieve and manipulate data.
Advantages and disadvantages of ASP
• Advantages-

1. Ease of Learning: Classic ASP is relatively easy to learn, making it accessible to developers,
even those new to web development.

2. Rapid Development: It allows for quick development of dynamic web pages with server-side
scripting capabilities.

3. Flexibility: Being a scripted language, VB Script (the underlying code) is easy to modify and
develop, requiring only a simple text editor for code changes.

4. Cost-Effective Edits: Edits are straightforward and less risky, making some development
updates faster and more cost-effective.

5. Simplicity: Classic ASP is a simpler technology, which often translates to fewer opportunities for
things to go wrong.
• Disadvantages-
1. Inline Code: Each file effectively has its own inline code, making site-wide changes (e.g.,
layouts) difficult without modifying templates1.
2. Limited Reusability: Reusing code and functionality across the website can be challenging.
3. Outdated Technology: Classic ASP lacks modern features and paradigms found in newer
technologies like ASP.NET.
4. Maintenance Challenges: As projects grow, maintaining Classic ASP applications becomes
more complex.
5.Security Risks: Classic ASP may have security vulnerabilities due to its
age and lack of built-in security features.
6. Scalability: It may not scale well for large, complex applications.
7. Performance: Classic ASP can be less performant compared to newer alternatives.
8. Lack of Separation of Concerns: It doesn’t enforce clear separation between presentation,
business logic, and data access.
9. Limited Community Support: The community around Classic ASP has diminished over
time.
10.Transition to ASP.NET: Migrating from Classic ASP to ASP.NET can be a significant
effort, especially for legacy systems.
Get and Post Methods in ASP
In Classic ASP, you can use the GET and POST methods to handle data sent from a client
(usually a web browser) to the server. Remember that the choice between GET and POST depends on
the nature of the data you’re handling. Use GET for simple queries or when data doesn’t need to be
hidden, and use POST for sensitive or large data.

GET Method:

• The GET method is commonly used to retrieve data from the server. It appends data to the URL as
query parameters.

• When a user submits a form using the GET method, the form data is included in the URL.

• To access the data sent via GET, you can use the Request.QueryString("parameter_name") method
in your ASP code.
Example HTML form using GET
1) Process.html
<form name="myForm" method="get"
action="process.asp">
<!-- form components -->
</form>
In the process.asp file, you can retrieve the values like
this:
2) Process.asp
Dim a
a= Request.QueryString("parameter_name")
Response.Write "Value received via GET: " & a
POST Method:
• The POST method is used to send data to the server securely. It does not expose data in
the URL.

• When a user submits a form using the POST method, the form data is sent in the request
body.

• To access the data sent via POST, you can use the Request.Form("parameter_name")
method in your ASP code.
• Example HTML form using POST
1)process.html
<form name="myForm" method="get" action="process.asp">
<!-- form components -->
</form>
2) process.asp
Dim a
a = Request.Form("parameter_name")
Response.Write "Value received via POST: " & a
Datatypes in Asp

In classic ASP, variable data types are implicitly determined based on the value
assigned to them. However, there are a few basic data types that are commonly used:
1) Variant: Variant is the most common data type in classic ASP, and it can hold any
type of data, including numbers, strings, dates, and objects. Variants are dynamically
typed, meaning they can change data types as needed.
• Example-
<%
' Variant data type (implicitly declared)
Dim var1
var1 = "Hello" ' Now var1 is a string
var1 = 10 ' Now var1 is an integer
var1 = True ' Now var1 is a Boolean
%>
2
2) String: Strings are sequences of characters enclosed in double quotes ("). They are used to
store textual data.
Example
<%
Dim str1
str1 = "This is a string"
%>

3) Integer: Integers are whole numbers without any decimal points. In classic ASP, integers are
typically represented as 16-bit signed integers, which have a range of -32,768 to 32,767.
Example:-
<%
Dim int1
int1 = 42
%>
4)Double: Doubles are floating-point numbers that can represent decimal values. They are used
to store numeric data with decimal points.
Example-
<%
Dim dbl1
dbl1 = 3.14
%>
5) Boolean: Booleans represent logical values of true or false. In classic ASP, true is represented
by -1 and false is represented by 0.
Example-
<%
Dim bool1
bool1 = True
%>
6)Date: Dates are used to represent dates and times. They are stored internally as floating-point
numbers, where the integer part represents the number of days since December 30, 1899, and the
fractional part represents the time.
<%
Dim dt1
dt1 = #4/1/2024 10:30:00 AM# ' April 1, 2024 at 10:30 AM
%>

You might also like