Monday, April 5, 2010

smallest circuit from IBM wich is trillionth of a square inch

Last week (October 24, 2002), IBM scientists announced that they've developed the smallest-ever logic circuit. The entire circuit covers less than a trillionth of a square inch. The equivalent circuit made from state-of-the-art silicon transistors takes up 260,000 times as much space. Although "logic circuits" can only complete simple calculation sorts of functions, the fact that these scientists used carbon monoxide compared to the traditional, larger-sized silicon molecules is a tangible leap into the nanotechnology edge for computer advancement.

IBM's recent announcement will be recorded as one more block in computing technology's trail - from strides in mechanical to electronic innovations. Circuits can be as simple as a working flashlight or as complex as your computer. But unlike a flashlight, a computer's integrated circuits - referred to as "chips" - move, store and process information as well as electricity. The most complex chips are called microprocessors, and they typically consist of silicon transistor circuits that basically function as on/off switches. If scientists and engineers can make smaller transistors, then they can make digital devices - like computers and hand-helds - smaller and more efficient.

Chip size regulates the size of digital devicesTo get a glimpse of how our wired (and wireless) society might live in the future, you'll need to understand how computers work and how historical innovations have shaped our modern world. So in this week's lesson you'll visit a cool website that takes you inside a computer, then you'll step into a history portal to meet some of the people who contributed to computing technology's development.
The Journey Inside

Intel was the first chip company to develop a microprocessor in 1971. More recently, they've created a great website that explains how computers do what they do. If you have Flash Player 4 or later installed on your system, click to The Journey Inside site to get started. (For a comparable HTML version, jump down this page for navigation through the Intel Museum Exhibits site.)

The Journey Inside entry pageFrom The Journey Inside, begin at the Introduction to Computers section and read through How to Navigate This Site, and look for the "go to activity" icons while you're at this website to find some interactive games. Move through the pages beginning at 01 - the History of Computers, and ending on page 07 - Which is Smarter - Human Brain or Computer? In reviewing this series, you'll learn how to identify the The Four Components of a Computer (input, storage, processing and output) and How Computers Process Information.

How is a computer similar and different from a toaster? How do the four components work together? How do you use these components on your computer, hand-held calculator, cell phone, or other devices? Would a faster computer affect how you use each of them?

A transistor gets placed in a microprocessing chipNext, check out the Circuits and Switches section. Here you'll learn how electricity works and how people harness its properties for daily uses. What is the difference between materials that resist and those that conduct electricity? What does this have to do with a working circuit?

Your next stop is Digital Information. This section is especially important for understanding how computers transfer and process information, since it answers the question, What is Binary Code? As you'll learn, binary code represents an on/off switch, similar to how circuits work in general. Things get more complex when an entire language is based on this system, meaning that a specific series of zeroes and ones can represent a letter, for example. What is ASCII? Can you explain how computers translate binary code into pictures you can see on your screen?

Now that you understand how information is transmitted, learn how it gets processed by reading the Microprocessors section. When you use your computer for various tasks, can you identify what your computer fetches, decodes and executes to fulfill your command? How are microprocessing chips made? How does the use of chemistry and electricity fit into the picture?

How a microprocessor transfers input dataFor a more detailed study of these concepts, or if you aren't using Flash, check out the Intel Museum Exhibits. This site is especially cool, because you can click on any underlined words to open a pop-up definition from the Technical Glossary.

Read through the different sections, How Transistors Work, How Chips Are Made, How Microprocessors Work, and Memory Technology. Review the questions for The Journey Inside exploratory above, and think about these additional questions as you move through the museum exhibits: Can you spell your own name in binary notation? What are p and n-types of silicon? How could IBM's carbon monoxide breakthrough replace these silicon-based uses?
The Computer Age Grows Up

A room-sized computer in 1946Sometimes it's hard to imagine, but electronic computers were first created just after World War II - that's nearly 60 years ago! But while we're used to our portable package of silicon chips on the desktop, the Computer Age spent its childhood as room-sized computers composed of huge vacuum tubes.

Travel back in history to the Computer History Museum's Timeline and see how computing technology got started and evolved over the years. You can begin your journey at either end of the timeline - 1945 or 1990 - and work your way to the other end. Doing this will show you each year's historic events under several topics. Alternatively, you can explore the history of each topic - Computers, People & Pop Culture, Software and Languages, Components, Robots and AI ("Artificial Intelligence"), Networks, and Companies.

What specific innovations did you find most interesting? Can you make any connections between those events and some use of modern technology? How were the scientists that contributed to these new inventions and ideas different from or similar to the ones who announced the carbon monoxide transistor? What kinds of interests do you think these scientists have that drives them to study, experiment and develop new computer technologies?
reference: 

adding java script to your web

Did you ask yourself why in blogspot posts some javascript code works but in some cases don't. In this article you will find answer.

In HTML\Jscript gadgets jscript code work well. But this is not a case in posts.

For example I added this code to my blogspot post and it didn't working.

Test


I couldn't understand why this code doesn't working in blogspot post but in my HTML editor work.
Later I found that this jscript code works well in blogspot post:

Test


Conclusion is that if you put jscript code inside quote code will work. But I was not satisfied with this because I wanted to use jscript function and reuse function code (for example function showMessage() called from multiple places in post). And I didn't find answer how to put jscript function in quote.

Somewhere I founded tip to make jscript file with jscript code and put this file on the web. After that call jscript function addressing that file.

It shold look something like this:



I think that this method have too many steps and that is too complicated (you must upload you jscript file somewhere on the web and later call this file from your blogspot post).

After rejecting this method, I take look at my blog source (View source):



There is a problem. In new line. Every time you have new line blogger editor add
tag. Because of this
tag web browser can't execute jscript.

So correct solution for my problem should look like this:

Test


To work well javascript in blogger post should be in one line.
to learn jscript:- 

Monday, March 29, 2010

Mesh Networks

A key component of the ZigBee protocol is the ability to support mesh networking. In a mesh network, nodes are interconnected with other nodes so that multiple pathways connect each node. Connections between nodes are dynamically updated and optimized through sophisticated, built-in mesh routing table.

Mesh networks are decentralized in nature; each node is capable of self-discovery on the network. Also, as nodes leave the network, the mesh topology allows the nodes to reconfigure routing paths based on the new network structure. The characteristics of mesh topology and ad-hoc routing provide greater stability in changing conditions or failure at single nodes.
ZigBee Applications

ZigBee enables broad-based deployment of wireless networks with low-cost, low-power solutions. It provides the ability to run for years on inexpensive batteries for a host of monitoring and control applications. Smart energy/smart grid, AMR (Automatic Meter Reading), lighting controls, building automation systems, tank monitoring, HVAC control, medical devices and fleet applications are just some of the many spaces where ZigBee technology is making significant advancements.
Digi ZigBee Technology

Digi is a member of the ZigBee Alliance and has developed a wide range of networking solutions based on the ZigBee protocol. XBee and XBee-PRO modules and other XBee-enabled devices provide an easy-to-implement solution that provides functionality to connect to a wide variety of devices.

ZigBee protocol features include:

* Support for multiple network topologies such as point-to-point, point-to-multipoint and mesh networks
* Low duty cycle – provides long battery life
* Low latency
* Direct Sequence Spread Spectrum (DSSS)
* Up to 65,000 nodes per network
* 128-bit AES encryption for secure data connections
* Collision avoidance, retries and acknowledgements

802.15.4 – ZigBee Physical Layer

ZigBee is a wireless technology developed as an open global standard to address the unique needs of low-cost, low-power wireless M2M networks. The ZigBee standard operates on the IEEE 802.15.4 physical radio specification and operates in unlicensed bands including 2.4 GHz, 900 MHz and 868 MHz.


The 802.15.4 specification upon which the ZigBee stack operates gained ratification by the Institute of Electrical and Electronics Engineers (IEEE) in 2003. The specification is a packet-based radio protocol intended for low-cost, battery-operated devices. The protocol allows devices to communicate in a variety of network topologies and can have battery life lasting several years.
The ZigBee Protocol

The ZigBee protocol has been created and ratified by member companies of the ZigBee Alliance. Over 300 leading semiconductor manufacturers, technology firms, OEMs and service companies comprise the ZigBee Alliance membership. The ZigBee protocol was designed to provide an easy-to-use wireless data solution characterized by secure, reliable wireless network architectures.
The ZigBee Advantage

The ZigBee protocol is designed to communicate data through hostile RF environments that are common in commercial and industrial applications.

ZigBee/IEEE802.15.4 - Typical Traffic Types Addressed

* Periodic data
* Application defined rate (e.g., sensors)
* Intermittent data
* Application/external stimulus defined rate (e.g., light switch)
* Repetitive low latency data

ZigBee/IEEE 802.15.4 - General Characteristics:

* Dual PHY (2.4GHz and 868/915 MHz)
* Data rates of 250 kbps (@2.4 GHz), 40 kbps (@ 915 MHz), and 20 kbps (@868 MHz)
* Optimized for low duty-cycle applications (<0.1%)
* CSMA-CA channel access Yields high throughput and low latency for low duty cycle devices like sensors and controls
* Low power (battery life multi-month to years)
* Multiple topologies: star, peer-to-peer, mesh
* Addressing space of up to:
- 18,450,000,000,000,000,000 devices (64 bit IEEE address)
- 65,535 networks
* Optional guaranteed time slot for applications requiring low latency
* Fully hand-shaked protocol for transfer reliability
* Range: 50m typical (5-500m based on environment)

ZigBee The ZigBee logo



The ZigBee specification is a combination of HomeRF Lite and the 802.15.4 specification. The spec operates in the 2.4GHz (ISM) radio band - the same band as 802.11b standard, Bluetooth, microwaves and some other devices. It is capable of connecting 255 devices per network. The specification supports data transmission rates of up to 250 Kbps at a range of up to 30 meters. ZigBee's technology is slower than 802.11b (11 Mbps) and Bluetooth (1 Mbps) but it consumes significantly less power.

What is ZigBee

The mission of the ZigBee Working Group is to bring about the existence of a broad range of interoperable consumer devices by establishing open industry specifications for unlicensed, untethered peripheral, control and entertainment devices requiring the lowest cost and lowest power consumption communications between compliant devices anywhere in and around the home.

The ZigBee membership includes Philips, Honeywell and Invensys Metering Systems, and others and is responsible for defining and maintaining higher layers above the MAC. The alliance is also developing application profiles, certification programs, logos and a marketing strategy. Philips Semiconductors and other chip vendors plan to launch their first ZigBee products as early as 2003. ZigBee was formerly known as PURLnet, RF-Lite, Firefly, and HomeRF Lite.

Nintendo® Wi-Fi Connection puts you in touch with players

Nintendo® Wi-Fi Connection puts you in touch with players everywhere - from across the room to across the globe. Use Friend Codes to play online with specific people, or compete anonymously through worldwide matchmaking. With millions of people online, there's always someone ready to play!

wi-fi defenition its certification uses and versions

wi-fi defenitions
Wi-Fi (short for "wireless fidelity") is a term for certain types of wireless local area network (WLAN) that use specifications in the 802.11 family. The term Wi-Fi was created by an organization called the Wi-Fi Alliance, which oversees tests that certify product interoperability. A product that passes the alliance tests is given the label "Wi-Fi certified" (a registered trademark).

Originally, Wi-Fi certification was applicable only to products using the 802.11b standard. Today, Wi-Fi can apply to products that use any 802.11 standard. The 802.11 specifications are part of an evolving set of wireless network standards known as the 802.11 family. The particular specification under which a Wi-Fi network operates is called the "flavor" of the network. Wi-Fi has gained acceptance in many businesses, agencies, schools, and homes as an alternative to a wired LAN. Many airports, hotels, and fast-food facilities offer public access to Wi-Fi networks. These locations are known as hot spots. Many charge a daily or hourly rate for access, but some are free. An interconnected area of hot spots and network access points is known as a hot zone.

Unless adequately protected, a Wi-Fi network can be susceptible to access by unauthorized users who use the access as a free Internet connection. The activity of locating and exploiting security-exposed wireless LANs is called war driving. An identifying iconography, called war chalking, has evolved. Any entity that has a wireless LAN should use security safeguards such as the Wired Equivalent Privacy (WEP) encryption standard, the more recent Wi-Fi Protected Access (WPA), Internet Protocol Security (IPsec), or a virtual private network (VPN).

How to Retrieve a Cookie Value?

The "Request.Cookies" command is used to retrieve a cookie value.
In the example below, we retrieve the value of the cookie named "firstname" and display it on a page:

<% fname=Request.Cookies("firstname") response.write("Firstname=" & fname) %>
Output: Firstname=Alex

What is a Cookie? & How to Create a Cookie?

A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too. With ASP, you can both create and retrieve cookie values.

How to Create a Cookie?
The "Response.Cookies" command is used to create cookies.
Note: The Response.Cookies command must appear BEFORE the tag.
In the example below, we will create a cookie named "firstname" and assign the value "Alex" to it:
<% Response.Cookies("firstname")="Alex" %>
It is also possible to assign properties to a cookie, like setting a date when the cookie should expire:
<% Response.Cookies("firstname")="Alex" Response.Cookies("firstname").Expires=#May 10,2012# %>

Everything you need to know about cookies: How to create them, make them, bake them

Saturday, March 27, 2010

DRDO scientist entry Chemical Engineering – CH

Process Calculations and Thermodynamics: Laws of conservation of mass and energy; use of tie components; recycle, bypass and purge calculations; degree of freedom analysis. First and Second laws of thermodynamics. First law application to close and open systems. Second law and Entropy Thermodynamic properties of pure substances: equation of state and departure function, properties of mixtures: partial molar properties, fugacity, excess properties and activity coefficients; phase equilibria: predicting VLE of systems; chemical reaction equilibria.
Fluid Mechanics and Mechanical Operations: Fluid statics, Newtonian and non-Newtonian fluids, Bernoulli equation, Macroscopic friction factors, energy balance, dimensional analysis, shell balances, flow through pipeline systems, flow meters, pumps and compressors, packed and fluidized beds, elementary boundary layer theory, size reduction and size separation; free and hindered settling; centrifuge and cyclones; thickening and classification, filtration, mixing and agitation; conveying of solids.
Heat Transfer: Conduction, convection and radiation, heat transfer coefficients, steady and unsteady heat conduction, boiling, condensation and evaporation; types of heat exchangers and evaporators and their design.
Mass Transfer: Fick’s laws, molecular diffusion in fluids, mass transfer coefficients, film, penetration and surface renewal theories; momentum, heat and mass transfer analogies; stagewise and continuous contacting and stage efficiencies; HTU & NTU concepts design and operation of equipment for distillation, absorption, leaching, liquid-liquid extraction, drying, humidification, dehumidification and adsorption.
Chemical Reaction Engineering: Theories of reaction rates; kinetics of homogeneous reactions, interpretation of kinetic data, single and multiple reactions in ideal reactors, non-ideal reactors; residence time distribution, single parameter model; non-isothermal reactors; kinetics of heterogeneous catalytic reactions; diffusion effects in catalysis.
Instrumentation and Process Control: Measurement of process variables; sensors, transducers and their dynamics, transfer functions and dynamic responses of simple systems, process reaction curve, controller modes (P, PI, and PID); control valves; analysis of closed loop systems including stability, frequency response and controller tuning, cascade, feed forward control.
Plant Design and Economics: Process design and sizing of chemical engineering equipment such as compressors, heat exchangers, multistage contactors; principles of process economics and cost estimation including total annualized cost, cost indexes, rate of return, payback period, discounted cash flow, optimization in design.Chemical Technology: Inorganic chemical industries; sulfuric acid, NaOH, fertilizers (Ammonia, Urea, SSP and TSP); natural products industries (Pulp and Paper, Sugar, Oil, and Fats); petroleum refining and petrochemicals; polymerization industries; polyethylene, polypropylene, PVC and polyester synthetic fibers.

DRDO scientist entry Computer Science and Engineering – CS

.
Theory of Computation: Regular languages and finite automata, Context free languages and Push-down automata, Recursively enumerable sets and Turing machines, Undecidability; NP-completeness.
Digital Logic: Logic functions, Minimization, Design and synthesis of combinational and sequential circuits; Number representation and computer arithmetic (fixed and floating point).
Computer Organization and Architecture: Machine instructions and addressing modes, ALU and data-path, CPU control design, Memory interface, I/O interface (Interrupt and DMA mode), Instruction pipelining, Cache and main memory, Secondary storage.
Programming and Data Structures: Programming in C; Functions, Recursion, Parameter passing, Scope, Binding; Abstract data types, Arrays, Stacks, Queues, Linked Lists, Trees, Binary search trees, Binary heaps. Algorithms: Analysis, Asymptotic notation, Notions of space and time complexity, Worst and average case analysis; Design: Greedy approach, Dynamic programming, Divide-and-conquer; Tree and graph traversals, Connected components, Spanning trees, Shortest paths; Hashing, Sorting, Searching.
Compiler Design: Lexical analysis, Parsing, Syntax directed translation, Runtime environments, Intermediate and target code generation, Basics of code optimization.
Operating System: Processes, Threads, Inter-process communication, Concurrency, Synchronization, Deadlock, CPU scheduling, Memory management and virtual memory, File systems, I/O systems, Protection and security.
Databases: ER-model, Relational model (relational algebra, tuple calculus), Database design (integrity constraints, normal forms), Query languages (SQL), File structures (sequential files, indexing, B and B+ trees), Transactions and concurrency control.
Computer Networks: ISO/OSI stack, LAN technologies (Ethernet, Token ring), Flow and error control techniques, Routing algorithms, Congestion control, TCP/UDP and sockets, IP(v4), Application layer protocols (icmp, dns, smtp, pop, ftp, http); Basic concepts of hubs, switches, gateways, and routers

DRDO scientist entry Electronics and Communication Engineering – EC

Networks: Network graphs: matrices associated with graphs; incidence, fundamental cut set and fundamental circuit matrices. Solution methods: nodal and mesh analysis. Network theorems: superposition, Thevenin and Norton’s maximum power transfer, Wye-Delta transformation. Steady state sinusoidal analysis using phasors. Linear constant coefficient differential equations; time domain analysis of simple RLC circuits, Solution of network equations using Laplace transform: frequency domain analysis of RLC circuits. 2-port network parameters: driving point and transfer functions. State equations for networks.
Electronic Devices: Energy bands in silicon, intrinsic and extrinsic silicon. Carrier transport in silicon: diffusion current, drift current, mobility, and resistivity. Generation and recombination of carriers. p-n junction diode, Zener diode, tunnel diode, BJT, JFET, MOS capacitor, MOSFET, LED, p-I-n and avalanche photo diode, Basics of LASERs. Device technology: integrated circuits fabrication process, oxidation, diffusion, ion implantation, photolithography, n-tub, p-tub and twin-tub CMOS process.
Analog Circuits: Small Signal Equivalent circuits of diodes, BJTs, MOSFETs and analog CMOS. Simple diode circuits, clipping, clamping, rectifier. Biasing and bias stability of transistor and FET amplifiers. Amplifiers: single-and multi-stage, differential and operational, feedback, and power. Frequency response of amplifiers. Simple op-amp circuits. Filters. Sinusoidal oscillators; criterion for oscillation; single-transistor and op-amp configurations. Function generators and wave-shaping circuits, 555 Timers. Power supplies.
Digital Circuits: Boolean algebra, minimization of Boolean functions; logic gates; digital IC families (DTL, TTL, ECL, MOS, CMOS). Combinatorial circuits: arithmetic circuits, code converters, multiplexers, decoders, PROMs and PLAs. Sequential circuits: latches and flip-flops, counters and shift-registers. Sample and hold circuits, ADCs, DACs. Semiconductor memories. Microprocessor(8085): architecture, programming, memory and I/O interfacing.
Signals and Systems: Definitions and properties of Laplace transform, continuous-time and discrete-time Fourier series, continuous-time and discrete-time Fourier Transform, DFT and FFT, z-transform. Sampling theorem. Linear Time-Invariant (LTI) Systems: definitions and properties; causality, stability, impulse response, convolution, poles and zeros, parallel and cascade structure, frequency response, group delay, phase delay. Signal transmission through LTI systems.
Control Systems: Basic control system components; block diagrammatic description, reduction of block diagrams. Open loop and closed loop (feedback) systems and stability analysis of these systems. Signal flow graphs and their use in determining transfer functions of systems; transient and steady state analysis of LTI control systems and frequency response. Tools and techniques for LTI control system analysis: root loci, Routh-Hurwitz criterion, Bode and Nyquist plots. Control system compensators: elements of lead and lag compensation, elements of Proportional-Integral-Derivative (PID) control. State variable representation and solution of state equation of LTI control systems.
Communications: Random signals and noise: probability, random variables, probability density function, autocorrelation, power spectral density. Analog communication systems: amplitude and angle modulation and demodulation systems, spectral analysis of these operations, superheterodyne receivers; elements of hardware, realizations of analog communication systems; signal-to-noise ratio (SNR) calculations for amplitude modulation (AM) and frequency modulation (FM) for low noise conditions. Fundamentals of information theory and channel capacity theorem. Digital communication systems: pulse code modulation (PCM), differential pulse code modulation (DPCM), digital modulation schemes: amplitude, phase and frequency shift keying schemes (ASK, PSK, FSK), matched filter receivers, bandwidth consideration and probability of error calculations for these schemes. Basics of TDMA, FDMA and CDMA and GSM.
Electromagnetics: Elements of vector calculus: divergence and curl; Gauss’ and Stokes’ theorems, Maxwell’s equations: differential and integral forms. Wave equation, Poynting vector. Plane waves: propagation through various media; reflection and refraction; phase and group velocity; skin depth. Transmission lines: characteristic impedance; impedance transformation; Smith chart; impedance matching; S parameters, pulse excitation. Waveguides: modes in rectangular waveguides; boundary conditions; cut-off frequencies; dispersion relations. Basics of propagation in dielectric waveguide and optical fibers. Basics of Antennas: Dipole antennas; radiation pattern; antenna gain.

DRDO scientist entry Electrical Engineering – EE

Electric Circuits and Fields: Network graph, KCL, KVL, node and mesh analysis, transient response of dc and ac networks; sinusoidal steady-state analysis, resonance, basic filter concepts; ideal current and voltage sources, Thevenin’s, Norton’s and Superposition and Maximum Power Transfer theorems, two-port networks, three phase circuits; Gauss Theorem, electric field and potential due to point, line, plane and spherical charge distributions; Ampere’s and Biot-Savart’s laws; inductance; dielectrics; capacitance.
Signals and Systems: Representation of continuous and discrete-time signals; shifting and scaling operations; linear, time-invariant and causal systems; Fourier series representation of continuous periodic signals; sampling theorem; Fourier, Laplace and Z transforms.
Electrical Machines: Single phase transformer - equivalent circuit, phasor diagram, tests, regulation and efficiency; three phase transformers - connections, parallel operation; auto-transformer; energy conversion principles; DC machines - types, windings, generator characteristics, armature reaction and commutation, starting and speed control of motors; three phase induction motors - principles, types, performance characteristics, starting and speed control; single phase induction motors; synchronous machines – performance, regulation and parallel operation of generators, motor starting, characteristics and applications; servo and stepper motors.
Power Systems: Basic power generation concepts; transmission line models and performance; cable performance, insulation; corona and radio interference; distribution systems; per-unit quantities; bus impedance and admittance matrices; load flow; voltage control; power factor correction; economic operation; symmetrical components; fault analysis; principles of over-current, differential and distance protection; solid state relays and digital protection; circuit breakers; system stability concepts, swing curves and equal area criterion; HVDC transmission and FACTS concepts.
Control Systems: Principles of feedback; transfer function; block diagrams; steady-state errors; Routh and Niquist techniques; Bode plots; root loci; lag, lead and lead-lag compensation; state space model; state transition matrix, controllability and observability. Electrical and Electronic Measurements: Bridges and potentiometers; PMMC, moving iron, dynamometer and induction type instruments; measurement of voltage, current, power, energy and power factor; instrument transformers; digital voltmeters and multimeters; phase, time and frequency measurement; Q-meters; oscilloscopes; potentiometric recorders; error analysis.
Analog and Digital Electronics: Characteristics of diodes, BJT, FET; amplifiers – biasing, equivalent circuit and frequency response; oscillators and feedback amplifiers; operational amplifiers - characteristics and applications; simple active filters; VCOs and timers; combinational and sequential logic circuits; multiplexer; Schmitt trigger; multi-vibrators; sample and hold circuits; A/D and D/A converters; 8-bit microprocessor basics, architecture, programming and interfacing.
Power Electronics and Drives: Semiconductor power diodes, transistors, thyristors, triacs, GTOs, MOSFETs and IGBTs - static characteristics and principles of operation; triggering circuits; phase control rectifiers; bridge converters – fully controlled and half controlled; principles of choppers and inverters; basis concepts of adjustable speed dc and ac drives.

DRDO scientist entry test Mechanical Engineering – ME

Engineering Mechanics: Free body diagrams and equilibrium; trusses and frames; virtual work; kinematics
and dynamics of particles and of rigid bodies in plane motion, including impulse and momentum (linear and
angular) and energy formulations; impact.
Strength of Materials: Stress and strain, stress-strain relationship and elastic constants, Mohr’s circle for
plane stress and plane strain, thin cylinders; shear force and bending moment diagrams; bending and shear
stresses; deflection of beams; torsion of circular shafts; Euler’s theory of columns; strain energy methods;
thermal stresses.
Theory of Machines: Displacement, velocity and acceleration analysis of plane mechanisms; dynamic analysis of slider-crank mechanism; gear trains; flywheels.
Vibrations: Free and forced vibration of single degree of freedom systems; effect of damping; vibration isolation; resonance, critical speeds of shafts.
Design: Design for static and dynamic loading; failure theories; fatigue strength and the S-N diagram; principles of the design of machine elements such as bolted, riveted and welded joints, shafts, spur gears, rolling and sliding contact bearings, brakes and clutches.
Fluid Mechanics: Fluid properties; fluid statics, manometry, buoyancy; control-volume analysis of mass, momentum and energy; fluid acceleration; differential equations of continuity and momentum; Bernoulli’s equation; viscous flow of incompressible fluids; boundary layer; elementary turbulent flow; flow through pipes, head losses in pipes, bends etc.
Heat-Transfer: Modes of heat transfer; one dimensional heat conduction, resistance concept, electrical analogy, unsteady heat conduction, fins; dimensionless parameters in free and forced convective heat transfer, various correlations for heat transfer in flow over flat plates and through pipes; thermal boundary layer; effect of turbulence; radiative heat transfer, black and grey surfaces, shape factors, network analysis; heat exchanger performance, LMTD and NTU methods.
Thermodynamics: Zeroth, First and Second laws of thermodynamics; thermodynamic system and processes; Carnot cycle. irreversibility and availability; behaviour of ideal and real gases, properties of pure substances, calculation of work and heat in ideal processes; analysis of thermodynamic cycles related to energy conversion.
Applications: Power Engineering: Steam Tables, Rankine, Brayton cycles with regeneration and reheat. I.C. Engines: air-standard Otto, Diesel cycles. Refrigeration and air-conditioning: Vapour refrigeration cycle, heat pumps, gas refrigeration, Reverse Brayton cycle; moist air: psychrometric chart, basic psychrometric processes. Turbomachinery: Pelton-wheel, Francis and Kaplan turbines — impulse and reaction principles, velocity diagrams.
Engineering Materials: Structure and properties of engineering materials, heat treatment, stress-strain diagrams for engineering materials.
Metal Casting: Design of patterns, moulds and cores; solidification and cooling; riser and gating design, design considerations.
Forming: Plastic deformation and yield criteria; fundamentals of hot and cold working processes; load estimation for bulk (forging, rolling, extrusion, drawing) and sheet (shearing, deep drawing, bending) metal forming processes; principles of powder metallurgy.
Joining: Physics of welding, brazing and soldering; adhesive bonding; design considerations in welding.
Machining and Machine Tool Operations: Mechanics of machining, single and multi-point cutting tools, tool geometry and materials, tool life and wear; economics of machining; principles of non-traditional machining processes; principles of work holding, principles of design of jigs and fixtures Metrology and Inspection: Limits, fits and tolerances; linear and angular measurements; comparators; gauge design; interferometry; form and finish measurement; alignment and testing methods; tolerance analysis in manufacturing and assembly.
• Computer Integrated Manufacturing: Basic concepts of CAD/CAM and their integration tools.
• Production Planning and Control: Forecasting models, aggregate production planning, scheduling, materials requirement planning.
• Inventory Control: Deterministic and probabilistic models; safety stock inventory control systems.
• Operations Research: Linear programming, simplex and duplex method, transportation, assignment, network flow models, simple queuing models, PERT and CPM.

Monday, March 22, 2010

Session_OnStart Event of asp

The Session_OnStart event occurs when the server creates a session. This event is placed in the Global.asa file. Session_OnEnd Event The Session_OnEnd event occurs when the session ends (abandoned or times out). This event is placed in the Global.asa file. Note: The MapPath method cannot be used in the Session_OnEnd code. Syntax ________________________________________ Examples Global.asa: To display the number of current visitors in an ASP file:

There are <%response.write(Application("visitors"))%> online now!

The Contents.RemoveAll method

The Contents.RemoveAll method deletes all items from the Contents collection. Syntax Application.Contents.RemoveAll() Session.Contents.RemoveAll() Example for the Application Object <% Application.Contents.RemoveAll() %> Example for the Session Object <% Session.Contents.RemoveAll() %> Events: ASP Session_OnStart and Session_OnEnd Events

The Timeout property sets or returns the timeout period for the Session object for this application, in minutes

. If the user does not refresh or request a page within the timeout period, the session will end. Syntax Session.Timeout[=nMinutes] Parameter Description nMinutes The number of minutes a session can remain idle before the server terminates it. Default is 20 minutes Examples <% response.write(" ") response.write("Default Timeout is: " & Session.Timeout) response.write(" ") Session.Timeout=30 response.write(" ") response.write("Timeout is now: " & Session.Timeout) response.write(" ") %> Output: Default Timeout is: 20 Timeout is now: 30 Methods: ASP Abandon Method ________________________________________ The Abandon method destroys a user session. Note: When this method is called, the current Session object is not deleted until all of the script on the current page have been processed. This means that it is possible to access session variables on the same page as the call to Abandon, but not from another Web page. Syntax Session.Abandon Examples File1.asp: <% Session("name")="Hege" Session.Abandon Response.Write(Session("name")) %> Output: Hege File2.asp: <% Response.Write(Session("name")) %> Output: (none) ASP Contents.Remove Method ________________________________________ The Contents.Remove method deletes an item from the Contents collection. Syntax Application.Contents.Remove(name|index) Session.Contents.Remove(name|index) Parameter Description name The name of the item to remove index The index of the item to remove ________________________________________ Examples for the Application Object Example 1 <% Application("test1")=("First test") Application("test2")=("Second test") Application("test3")=("Third test") Application.Contents.Remove("test2") for each x in Application.Contents Response.Write(x & "=" & Application.Contents(x) & " ") next %> Output: test1=First test test3=Third test Example 2 <% Application("test1")=("First test") Application("test2")=("Second test") Application("test3")=("Third test") Application.Contents.Remove(2) for each x in Application.Contents Response.Write(x & "=" & Application.Contents(x) & " ") next %> Output: test1=First test test3=Third test Examples for the Session Object Example 1 <% Session("test1")=("First test") Session("test2")=("Second test") Session("test3")=("Third test") Session.Contents.Remove("test2") for each x in Session.Contents Response.Write(x & "=" & Session.Contents(x) & " ") next %> Output: test1=First test test3=Third test Example 2 <% Session("test1")=("First test") Session("test2")=("Second test") Session("test3")=("Third test") Session.Contents.Remove(2) for each x in Session.Contents Response.Write(x & "=" & Session.Contents(x) & " ") next %> Output: test1=First test test3=Third test ASP Contents.RemoveAll Method

The LCID property sets or returns an integer that specifies a location or region.

Contents like date, time, and currency will be displayed according to that location or region. Syntax Session.LCID(=LCID) Parameter Description LCID A locale identifier Examples <% response.write(" ") response.write("Default LCID is: " & Session.LCID & " ") response.write("Date format is: " & date() & " ") response.write("Currency format is: " & FormatCurrency(350)) response.write(" ") Session.LCID=1036 response.write(" ") response.write("LCID is now: " & Session.LCID & " ") response.write("Date format is: " & date() & " ") response.write("Currency format is: " & FormatCurrency(350)) response.write(" ") Session.LCID=3079 response.write(" ") response.write("LCID is now: " & Session.LCID & " ") response.write("Date format is: " & date() & " ") response.write("Currency format is: " & FormatCurrency(350)) response.write(" ") Session.LCID=2057 response.write(" ") response.write("LCID is now: " & Session.LCID & " ") response.write("Date format is: " & date() & " ") response.write("Currency format is: " & FormatCurrency(350)) response.write(" ") %> Output: Default LCID is: 2048 Date format is: 12/11/2001 Currency format is: $350.00 LCID is now: 1036 Date format is: 11/12/2001 Currency format is: 350,00 F LCID is now: 3079 Date format is: 11.12.2001 Currency format is: öS 350,00 LCID is now: 2057 Date format is: 11/12/2001 Currency format is: £350.00 ASP SessionID Property ________________________________________ The SessionID property returns a unique id for each user. The unique id is generated by the server. Syntax Session.SessionID Examples <% Response.Write(Session.SessionID) %> Output: 772766038 ASP Timeout Property

The StaticObjects collection contains all the objects appended to the application/session with the HTML tag

. Syntax Application.StaticObjects(Key) Session.StaticObjects(Key) Parameter Description key Required. The name of the item to retrieve ________________________________________ Examples for the Application Object Example 1 To loop through the StaticObjects collection: <% for each x in Application.StaticObjects Response.Write(x & " ") next %> Example 2 In Global.asa: In an ASP file: <% for each x in Application.StaticObjects Response.Write(x & " ") next %> Output: MsgBoard AdRot ________________________________________ Examples for the Session Object Example 1 To loop through the StaticObjects collection: <% for each x in Session.StaticObjects Response.Write(x & " ") next %> Example 2 In Global.asa: In an ASP file: <% for each x in Session.StaticObjects Response.Write(x & " ") next %> Output: MsgBoard AdRot Properties: ASP CodePage Property ________________________________________ The CodePage property specifies the character set that will be used when displaying dynamic content. Example of some code pages: • 1252 - American English and most European languages • 932 - Japanese Kanji Syntax Session.CodePage(=Codepage) Parameter Description codepage Defines a code page (character set) for the system running the script engine Examples <% Response.Write(Session.CodePage) %> Output: 1252 ASP LCID Property

ASP Session Object A Session object stores information about, or change settings for a user session.

________________________________________ Session Object When you are working with an application on your computer, you open it, do some changes and then you close it. This is much like a Session. The computer knows who you are. It knows when you open the application and when you close it. However, on the internet there is one problem: the web server does not know who you are and what you do, because the HTTP address doesn't maintain state. ASP solves this problem by creating a unique cookie for each user. The cookie is sent to the user's computer and it contains information that identifies the user. This interface is called the Session object. The Session object stores information about, or change settings for a user session. Variables stored in a Session object hold information about one single user, and are available to all pages in one application. Common information stored in session variables are name, id, and preferences. The server creates a new Session object for each new user, and destroys the Session object when the session expires. The Session object's collections, properties, methods, and events are described below: Collections Collection Description Contents Contains all the items appended to the session through a script command StaticObjects Contains all the objects appended to the session with the HTML tag Properties Property Description CodePage Specifies the character set that will be used when displaying dynamic content LCID Sets or returns an integer that specifies a location or region. Contents like date, time, and currency will be displayed according to that location or region SessionID Returns a unique id for each user. The unique id is generated by the server Timeout Sets or returns the timeout period (in minutes) for the Session object in this application Methods Method Description Abandon Destroys a user session Contents.Remove Deletes an item from the Contents collection Contents.RemoveAll() Deletes all items from the Contents collection Events Event Description Session_OnEnd Occurs when a session ends Session_OnStart Occurs when a session starts Collections: ASP Contents Collection ________________________________________ The Contents collection contains all the items appended to the application/session through a script command. Tip: To remove items from the Contents collection, use the Remove and RemoveAll methods. Syntax Application.Contents(Key) Session.Contents(Key) Parameter Description key Required. The name of the item to retrieve ________________________________________ Examples for the Application Object Example 1 Notice that both name and objtest would be appended to the Contents collection: <% Application("name")="W3Schools" Set Application("objtest")=Server.CreateObject("ADODB.Connection") %> Example 2 To loop through the Contents collection: <% for each x in Application.Contents Response.Write(x & "=" & Application.Contents(x) & " ") next %> or: <% For i=1 to Application.Contents.Count Response.Write(i & "=" & Application.Contents(i) & " ") Next %> Example 3 <% Application("date")="2001/05/05" Application("author")="W3Schools" for each x in Application.Contents Response.Write(x & "=" & Application.Contents(x) & " ") next %> Output: date=2001/05/05 author=W3Schools ________________________________________ Examples for the Session Object Example 1 Notice that both name and objtest would be appended to the Contents collection: <% Session("name")="Hege" Set Session("objtest")=Server.CreateObject("ADODB.Connection") %> Example 2 To loop through the Contents collection: <% for each x in Session.Contents Response.Write(x & "=" & Session.Contents(x) & " ") next %> or: <% For i=1 to Session.Contents.Count Response.Write(i & "=" & Session.Contents(i) & " ") Next %> Example 3 <% Session("name")="Hege" Session("date")="2001/05/05" for each x in Session.Contents Response.Write(x & "=" & Session.Contents(x) & " ") next %> Output: name=Hege date=2001/05/05 ASP StaticObjects Collection

Application Object of asp

An application on the Web may consists of several ASP files that work together to perform some purpose. The Application object is used to tie these files together. The Application object is used to store and access variables from any page, just like the Session object. The difference is that ALL users share ONE Application object (with Sessions there is ONE Session object for EACH user). The Application object holds information that will be used by many pages in the application (like database connection information). The information can be accessed from any page. The information can also be changed in one place, and the changes will automatically be reflected on all pages. The Application object's collections, methods, and events are described below: Collections Collection Description Contents Contains all the items appended to the application through a script command StaticObjects Contains all the objects appended to the application with the HTML tag Methods Method Description Contents.Remove Deletes an item from the Contents collection Contents.RemoveAll() Deletes all items from the Contents collection Lock Prevents other users from modifying the variables in the Application object Unlock Enables other users to modify the variables in the Application object (after it has been locked using the Lock method) Events Event Description Application_OnEnd Occurs when all user sessions are over, and the application ends Application_OnStart Occurs before the first new session is created (when the Application object is first referenced) Collections: ASP Contents Collection ________________________________________ The Contents collection contains all the items appended to the application/session through a script command. Tip: To remove items from the Contents collection, use the Remove and RemoveAll methods. Syntax Application.Contents(Key) Session.Contents(Key) Parameter Description key Required. The name of the item to retrieve ________________________________________ Examples for the Application Object Example 1 Notice that both name and objtest would be appended to the Contents collection: <% Application("name")="W3Schools" Set Application("objtest")=Server.CreateObject("ADODB.Connection") %> Example 2 To loop through the Contents collection: <% for each x in Application.Contents Response.Write(x & "=" & Application.Contents(x) & " ") next %> or: <% For i=1 to Application.Contents.Count Response.Write(i & "=" & Application.Contents(i) & " ") Next %> Example 3 <% Application("date")="2001/05/05" Application("author")="W3Schools" for each x in Application.Contents Response.Write(x & "=" & Application.Contents(x) & " ") next %> Output: date=2001/05/05 author=W3Schools ________________________________________ Examples for the Session Object Example 1 Notice that both name and objtest would be appended to the Contents collection: <% Session("name")="Hege" Set Session("objtest")=Server.CreateObject("ADODB.Connection") %> Example 2 To loop through the Contents collection: <% for each x in Session.Contents Response.Write(x & "=" & Session.Contents(x) & " ") next %> or: <% For i=1 to Session.Contents.Count Response.Write(i & "=" & Session.Contents(i) & " ") Next %> Example 3 <% Session("name")="Hege" Session("date")="2001/05/05" for each x in Session.Contents Response.Write(x & "=" & Session.Contents(x) & " ") next %> Output: name=Hege date=2001/05/05 ASP StaticObjects Collection ________________________________________ The StaticObjects collection contains all the objects appended to the application/session with the HTML tag. Syntax Application.StaticObjects(Key) Session.StaticObjects(Key) Parameter Description key Required. The name of the item to retrieve ________________________________________ Examples for the Application Object Example 1 To loop through the StaticObjects collection: <% for each x in Application.StaticObjects Response.Write(x & " ") next %> Example 2 In Global.asa: In an ASP file: <% for each x in Application.StaticObjects Response.Write(x & " ") next %> Output: MsgBoard AdRot ________________________________________ Examples for the Session Object Example 1 To loop through the StaticObjects collection: <% for each x in Session.StaticObjects Response.Write(x & " ") next %> Example 2 In Global.asa: In an ASP file: <% for each x in Session.StaticObjects Response.Write(x & " ") next %> Output: MsgBoard AdRot Methods: ASP Contents.Remove Method ________________________________________ The Contents.Remove method deletes an item from the Contents collection. Syntax Application.Contents.Remove(name|index) Session.Contents.Remove(name|index) Parameter Description name The name of the item to remove index The index of the item to remove ________________________________________ Examples for the Application Object Example 1 <% Application("test1")=("First test") Application("test2")=("Second test") Application("test3")=("Third test") Application.Contents.Remove("test2") for each x in Application.Contents Response.Write(x & "=" & Application.Contents(x) & " ") next %> Output: test1=First test test3=Third test Example 2 <% Application("test1")=("First test") Application("test2")=("Second test") Application("test3")=("Third test") Application.Contents.Remove(2) for each x in Application.Contents Response.Write(x & "=" & Application.Contents(x) & " ") next %> Output: test1=First test test3=Third test Examples for the Session Object Example 1 <% Session("test1")=("First test") Session("test2")=("Second test") Session("test3")=("Third test") Session.Contents.Remove("test2") for each x in Session.Contents Response.Write(x & "=" & Session.Contents(x) & " ") next %> Output: test1=First test test3=Third test Example 2 <% Session("test1")=("First test") Session("test2")=("Second test") Session("test3")=("Third test") Session.Contents.Remove(2) for each x in Session.Contents Response.Write(x & "=" & Session.Contents(x) & " ") next %> Output: test1=First test test3=Third test ASP Contents.RemoveAll Method ________________________________________ The Contents.RemoveAll method deletes all items from the Contents collection. Syntax Application.Contents.RemoveAll() Session.Contents.RemoveAll() Example for the Application Object <% Application.Contents.RemoveAll() %> Example for the Session Object <% Session.Contents.RemoveAll() %> ASP Lock and Unlock Methods ________________________________________ Lock Method The Lock method prevents other users from modifying the variables in the Application object (used to ensure that only one client at a time can modify the Application variables). Unlock Method The Unlock method enables other users to modify the variables stored in the Application object (after it has been locked using the Lock method). Syntax Application.Lock Application.Unlock Example The example below uses the Lock method to prevent more than one user from accessing the variable visits at a time, and the Unlock method to unlock the locked object so that the next client can increment the variable visits: <% Application.Lock Application("visits")=Application("visits")+1 Application.Unlock %> This page has been visited <%=Application("visits")%> times! Events: ASP Application_OnStart and Application_OnEnd Events ________________________________________ Application_OnStart Event The Application_OnStart event occurs before the first new session is created (when the Application object is first referenced). This event is placed in the Global.asa file. Note: Referencing to a Session, Request, or Response objects in the Application_OnStart event script will cause an error. Application_OnEnd Event The Application_OnEnd event occurs when the application ends (when the web server stops). This event is placed in the Global.asa file. Note: The MapPath method cannot be used in the Application_OnEnd code. Syntax ________________________________________ Examples Global.asa: To display the number of current visitors in an ASP file:

There are <%response.write(Application("visitors"))%> online now!

The ServerVariables collection is used to retrieve the server variable values.

Syntax Request.ServerVariables (server_variable) Parameter Description server_variable Required. The name of the server variable to retrieve Server Variables Variable Description ALL_HTTP Returns all HTTP headers sent by the client. Always prefixed with HTTP_ and capitalized ALL_RAW Returns all headers in raw form APPL_MD_PATH Returns the meta base path for the application for the ISAPI DLL APPL_PHYSICAL_PATH Returns the physical path corresponding to the meta base path AUTH_PASSWORD Returns the value entered in the client's authentication dialog AUTH_TYPE The authentication method that the server uses to validate users AUTH_USER Returns the raw authenticated user name CERT_COOKIE Returns the unique ID for client certificate as a string CERT_FLAGS bit0 is set to 1 if the client certificate is present and bit1 is set to 1 if the cCertification authority of the client certificate is not valid CERT_ISSUER Returns the issuer field of the client certificate CERT_KEYSIZE Returns the number of bits in Secure Sockets Layer connection key size CERT_SECRETKEYSIZE Returns the number of bits in server certificate private key CERT_SERIALNUMBER Returns the serial number field of the client certificate CERT_SERVER_ISSUER Returns the issuer field of the server certificate CERT_SERVER_SUBJECT Returns the subject field of the server certificate CERT_SUBJECT Returns the subject field of the client certificate CONTENT_LENGTH Returns the length of the content as sent by the client CONTENT_TYPE Returns the data type of the content GATEWAY_INTERFACE Returns the revision of the CGI specification used by the server HTTP_ Returns the value stored in the header HeaderName HTTP_ACCEPT Returns the value of the Accept header HTTP_ACCEPT_LANGUAGE Returns a string describing the language to use for displaying content HTTP_COOKIE Returns the cookie string included with the request HTTP_REFERER Returns a string containing the URL of the page that referred the request to the current page using an tag. If the page is redirected, HTTP_REFERER is empty HTTP_USER_AGENT Returns a string describing the browser that sent the request HTTPS Returns ON if the request came in through secure channel or OFF if the request came in through a non-secure channel HTTPS_KEYSIZE Returns the number of bits in Secure Sockets Layer connection key size HTTPS_SECRETKEYSIZE Returns the number of bits in server certificate private key HTTPS_SERVER_ISSUER Returns the issuer field of the server certificate HTTPS_SERVER_SUBJECT Returns the subject field of the server certificate INSTANCE_ID The ID for the IIS instance in text format INSTANCE_META_PATH The meta base path for the instance of IIS that responds to the request LOCAL_ADDR Returns the server address on which the request came in LOGON_USER Returns the Windows account that the user is logged into PATH_INFO Returns extra path information as given by the client PATH_TRANSLATED A translated version of PATH_INFO that takes the path and performs any necessary virtual-to-physical mapping QUERY_STRING Returns the query information stored in the string following the question mark (?) in the HTTP request REMOTE_ADDR Returns the IP address of the remote host making the request REMOTE_HOST Returns the name of the host making the request REMOTE_USER Returns an unmapped user-name string sent in by the user REQUEST_METHOD Returns the method used to make the request SCRIPT_NAME Returns a virtual path to the script being executed SERVER_NAME Returns the server's host name, DNS alias, or IP address as it would appear in self-referencing URLs SERVER_PORT Returns the port number to which the request was sent SERVER_PORT_SECURE Returns a string that contains 0 or 1. If the request is being handled on the secure port, it will be 1. Otherwise, it will be 0 SERVER_PROTOCOL Returns the name and revision of the request information protocol SERVER_SOFTWARE Returns the name and version of the server software that answers the request and runs the gateway URL Returns the base portion of the URL ________________________________________ Examples Example 1 You can loop through all of the server variables like this: <% for each x in Request.ServerVariables response.write(x & " ") next > Example 2 This example demonstrates how to find out the visitor's browser type, IP address, and more:

You are browsing this site with: <%Response.Write(Request.ServerVariables("http_user_agent"))%>

Your IP address is: <%Response.Write(Request.ServerVariables("remote_addr"))%>

The DNS lookup of the IP address is: <%Response.Write(Request.ServerVariables("remote_host"))%>

The method used to call the page: <%Response.Write(Request.ServerVariables("request_method"))%>

The server's domain name: <%Response.Write(Request.ServerVariables("server_name"))%>

The server's port: <%Response.Write(Request.ServerVariables("server_port"))%>

The server's software: <%Response.Write(Request.ServerVariables("server_software"))%>
Properties ASP TotalBytes Property ________________________________________ The TotalBytes property is a read-only property that returns the total number of bytes the client sent in the body of the request. Syntax varbytes=Request.Totalbytes Example The following code sets the variable a equal to the total number of bytes sent in the body of the request: <% dim a a=Request.TotalBytes %> ASP BinaryRead Method ________________________________________ The BinaryRead method is used to retrieve the data sent to the server from the client as part of a POST request. It will store the data in a safe array (an array that stores information about the number of dimensions and the bounds of its dimensions). Note: A call to Request.Form after a call to BinaryRead, and vice-versa, will cause an error. Syntax Request.BinaryRead(count) Parameter Description count Required. Specifies how many bytes to read from the client Examples The following example uses the BinaryRead method to place the content of a request into a safe array: <% dim a,b a=Request.TotalBytes b=Request.BinaryRead(a) %> 3) ASP Application Object A group of ASP files that work together to perform some purpose is called an application. The Application object is used to tie these files together.

2.ASP Request Object The Request object is used to get information from a visitor.

________________________________________ Request Object When a browser asks for a page from a server, it is called a request. The Request object is used to get information from a visitor. Its collections, properties, and methods are described below: Collections Collection Description ClientCertificate Contains all the field values stored in the client certificate Cookies Contains all the cookie values sent in a HTTP request Form Contains all the form (input) values from a form that uses the post method QueryString Contains all the variable values in a HTTP query string ServerVariables Contains all the server variable values Properties Property Description TotalBytes Returns the total number of bytes the client sent in the body of the request Methods Method Description BinaryRead Retrieves the data sent to the server from the client as part of a post request and stores it in a safe array Collections: ASP Cookies Collection ________________________________________ The Cookies collection is used to set or get cookie values. If the cookie does not exist, it will be created, and take the value that is specified. Note: The Response.Cookies command must appear before the tag. Syntax Response.Cookies(name)[(key)|.attribute]=value variablename=Request.Cookies(name)[(key)|.attribute] Parameter Description name Required. The name of the cookie value Required for the Response.Cookies command. The value of the cookie attribute Optional. Specifies information about the cookie. Can be one of the following parameters: • Domain - Write-only. The cookie is sent only to requests to this domain • Expires - Write-only. The date when the cookie expires. If no date is specified, the cookie will expire when the session ends • HasKeys - Read-only. Specifies whether the cookie has keys (This is the only attribute that can be used with the Request.Cookies command) • Path - Write-only. If set, the cookie is sent only to requests to this path. If not set, the application path is used • Secure - Write-only. Indicates if the cookie is secure key Optional. Specifies the key to where the value is assigned ________________________________________ Examples The "Response.Cookies" command is used to create a cookie or to set a cookie value: <% Response.Cookies("firstname")="Alex" %> In the code above, we have created a cookie named "firstname" and assigned the value "Alex" to it. It is also possible to assign some attributes to a cookie, like setting a date when a cookie should expire: <% Response.Cookies("firstname")="Alex" Response.Cookies("firstname").Expires=#May 10,2002# %> Now the cookie named "firstname" has the value of "Alex", and it will expire from the user's computer at May 10, 2002. The "Request.Cookies" command is used to get a cookie value. In the example below, we retrieve the value of the cookie "firstname" and display it on a page: <% fname=Request.Cookies("firstname") response.write("Firstname=" & fname) %> Output: Firstname=Alex A cookie can also contain a collection of multiple values. We say that the cookie has Keys. In the example below, we will create a cookie-collection named "user". The "user" cookie has Keys that contains information about a user: <% Response.Cookies("user")("firstname")="John" Response.Cookies("user")("lastname")="Smith" Response.Cookies("user")("country")="Norway" Response.Cookies("user")("age")="25" %> The code below reads all the cookies your server has sent to a user. Note that the code checks if a cookie has Keys with the HasKeys property: <% dim x,y for each x in Request.Cookies response.write(" ") if Request.Cookies(x).HasKeys then for each y in Request.Cookies(x) response.write(x & ":" & y & "=" & Request.Cookies(x)(y)) response.write(" " next %> %> Output: firstname=Alex user:firstname=John user:lastname=Smith user: country=Norway user: age=25 ASP Form Collection ________________________________________ The Form collection is used to retrieve the values of form elements from a form that uses the POST method. Syntax Request.Form(element)[(index)|.Count] Parameter Description element Required. The name of the form element from which the collection is to retrieve values index Optional. Specifies one of multiple values for a parameter. From 1 to Request.Form(parameter).Count. ________________________________________ Examples Example 1 You can loop through all the values in a form request. If a user filled out a form by specifying two values - Blue and Green - for the color element, you could retrieve those values like this: <% for i=1 to Request.Form("color").Count Response.Write(Request.Form("color")(i) & " ") next %> Output: Blue Green Example 2 Consider the following form:

First name:

Last name:

Your favorite color:

The following request might be sent: firstname=John&lastname=Dove&color=Red Now we can use the information from the form in a script: Hi, <%=Request.Form("firstname")%>. Your favorite color is <%=Request.Form("color")%>. Output: Hi, John. Your favorite color is Red. If you do not specify any element to display, like this: Form data is: <%=Request.Form%> the output would look like this: Form data is: firstname=John&lastname=Dove&color=Red ASP QueryString Collection ________________________________________ The QueryString collection is used to retrieve the variable values in the HTTP query string. The HTTP query string is specified by the values following the question mark (?), like this: Link with a query string The line above generates a variable named txt with the value "this is a query string test". Query strings are also generated by form submission, or by a user typing a query into the address bar of the browser. Note: If you want to send large amounts of data (beyond 100 kb) the Request.QueryString cannot be used. Syntax Request.QueryString(variable)[(index)|.Count] Parameter Description variable Required. The name of the variable in the HTTP query string to retrieve index Optional. Specifies one of multiple values for a variable. From 1 to Request.QueryString(variable).Count ________________________________________ Examples Example 1 To loop through all the n variable values in a Query String: The following request is sent: http://www.w3schools.com/test/names.asp?n=John&n=Susan and names.asp contains the following script: <% for i=1 to Request.QueryString("n").Count Response.Write(Request.QueryString("n")(i) & " ") next %> The file names.asp would display the following: John Susan Example 2 The following string might be sent: http://www.w3schools.com/test/names.asp?name=John&age=30 this results in the following QUERY_STRING value: name=John&age=30 Now we can use the information in a script: Hi, <%=Request.QueryString("name")%>. Your age is <%= Request.QueryString("age")%>. Output: Hi, John. Your age is 30. If you do not specify any variable values to display, like this: Query string is: <%=Request.QueryString%> the output would look like this: Query string is: name=John&age=30 ASP ServerVariables Collection

You can use HTML tags to format the text!

") %> <% response.write(" This text is styled with the style attribute! ") %> 3) Redirect the user to a different URL -How to redirect the user to a different URL. <% if Request.Form("select")<>"" then Response.Redirect(Request.Form("select")) end if %>
Server Example Text Example
4)Show a random link-How to create a random link. <% randomize() r=rnd() if r>0.5 then response.write("W3Schools.com!") else response.write("Refsnesdata.no!") end if %>

This example demonstrates a link, each time you load the page, it will display one of two links: W3Schools.com! OR Refsnesdata.no! There is a 50% chance for each of them.
5)Controlling the buffer-How to control the buffer. <% Response.Buffer=true %>

This text will be sent to your browser when my response buffer is flushed.
<% Response.Flush %> 6) Clear the buffer-How to clear the buffer. <% Response.Buffer=true %>

This is some text I want to send to the user.

No, I changed my mind. I want to clear the text.
<% Response.Clear %> 7) End a script in the middle of processing and return the result-How to end a script in the middle of processing.

I am writing some text. This text will never be <% Response.End %> finished! It's too late to write more!
8) Set how many minutes a page will be cached in a browser before it expires -How to specify how many minutes a page will be cached in a browser before it expires. <%Response.Expires=-1%>

This page will be refreshed with each access!
9)Set a date/time when a page cached in a browser will expire-How to specify a date/time a page cached in a browser will expire. <% Response.ExpiresAbsolute=#May 05,2001 05:30:30# %>

This page will expire on May 05, 2001 05:30:30!
10) Check if the user is still connected to the server-How to check if a user is disconnected from the server. <% If Response.IsClientConnected=true then Response.Write("The user is still connected!") else Response.Write("The user is not connected!") end if %> 11) Set the type of content-How to specify the type of content. <% Response.ContentType="text/html" %>

This is some text
12) Set the name of the character set-How to specify the name of the character set. <% Response.Charset="ISO8859-1" %>

This is some text

The Redirect method redirects the user to a different URL.

Syntax Response.Redirect URL Parameter Description URL Required. The URL that the user (browser) is redirected to Examples <% Response.Redirect "http://www.w3schools.com" %> ASP Write Method ________________________________________ The Write method writes a specified string to the output. Syntax Response.Write variant Parameter Description variant Required. The data to write ________________________________________ Examples Example 1 <% Response.Write "Hello World" %> Output: Hello World Example 2 <% name="John" Response.Write(name) %> Output: John Example 3 <% Response.Write("Hello World") %> Output: Hello World Try it Yourself – Examples 1)Write text with ASP- How to write text with ASP. <% response.write("Hello World!") %> 2) Format text with HTML tags in ASP- How to combine text and HTML tags with ASP. <% response.write("

Response Object

The ASP Response object is used to send output to the user from the server. Its collections, properties, and methods are described below: Collections Collection Description Cookies Sets a cookie value. If the cookie does not exist, it will be created, and take the value that is specified Properties Property Description Buffer Specifies whether to buffer the page output or not CacheControl Sets whether a proxy server can cache the output generated by ASP or not Charset Appends the name of a character-set to the content-type header in the Response object ContentType Sets the HTTP content type for the Response object Expires Sets how long (in minutes) a page will be cached on a browser before it expires ExpiresAbsolute Sets a date and time when a page cached on a browser will expire IsClientConnected Indicates if the client has disconnected from the server Pics Appends a value to the PICS label response header Status Specifies the value of the status line returned by the server Methods Method Description AddHeader Adds a new HTTP header and a value to the HTTP response AppendToLog Adds a string to the end of the server log entry BinaryWrite Writes data directly to the output without any character conversion Clear Clears any buffered HTML output End Stops processing a script, and returns the current result Flush Sends buffered HTML output immediately Redirect Redirects the user to a different URL Write Writes a specified string to the output ASP Cookies Collection ________________________________________ The Cookies collection is used to set or get cookie values. If the cookie does not exist, it will be created, and take the value that is specified. Note: The Response.Cookies command must appear before the tag. Syntax Response.Cookies(name)[(key)|.attribute]=value variablename=Request.Cookies(name)[(key)|.attribute] Parameter Description name Required. The name of the cookie value Required for the Response.Cookies command. The value of the cookie attribute Optional. Specifies information about the cookie. Can be one of the following parameters: • Domain - Write-only. The cookie is sent only to requests to this domain • Expires - Write-only. The date when the cookie expires. If no date is specified, the cookie will expire when the session ends • HasKeys - Read-only. Specifies whether the cookie has keys (This is the only attribute that can be used with the Request.Cookies command) • Path - Write-only. If set, the cookie is sent only to requests to this path. If not set, the application path is used • Secure - Write-only. Indicates if the cookie is secure key Optional. Specifies the key to where the value is assigned ________________________________________ Examples The "Response.Cookies" command is used to create a cookie or to set a cookie value: <% Response.Cookies("firstname")="Alex" %> In the code above, we have created a cookie named "firstname" and assigned the value "Alex" to it. It is also possible to assign some attributes to a cookie, like setting a date when a cookie should expire: <% Response.Cookies("firstname")="Alex" Response.Cookies("firstname").Expires=#May 10,2002# %> Now the cookie named "firstname" has the value of "Alex", and it will expire from the user's computer at May 10, 2002. The "Request.Cookies" command is used to get a cookie value. In the example below, we retrieve the value of the cookie "firstname" and display it on a page: <% fname=Request.Cookies("firstname") response.write("Firstname=" & fname) %> Output: Firstname=Alex A cookie can also contain a collection of multiple values. We say that the cookie has Keys. In the example below, we will create a cookie-collection named "user". The "user" cookie has Keys that contains information about a user: <% Response.Cookies("user")("firstname")="John" Response.Cookies("user")("lastname")="Smith" Response.Cookies("user")("country")="Norway" Response.Cookies("user")("age")="25" %> The code below reads all the cookies your server has sent to a user. Note that the code checks if a cookie has Keys with the HasKeys property: <% dim x,y for each x in Request.Cookies response.write(" ") if Request.Cookies(x).HasKeys then for each y in Request.Cookies(x) response.write(x & ":" & y & "=" & Request.Cookies(x)(y)) response.write(" " next %> %> Output: firstname=Alex user:firstname=John user:lastname=Smith user: country=Norway user: age=25 Properties: ASP Buffer Property The Buffer property specifies whether to buffer the output or not. When the output is buffered, the server will hold back the response to the browser until all of the server scripts have been processed, or until the script calls the Flush or End method. Note: If this property is set, it should be before the tag in the .asp file Syntax response.Buffer[=flag] Parameter Description flag A boolean value that specifies whether to buffer the page output or not. False indicates no buffering. The server will send the output as it is processed. False is default for IIS version 4.0 (and earlier). Default for IIS version 5.0 (and later) is true. True indicates buffering. The server will not send output until all of the scripts on the page have been processed, or until the Flush or End method has been called. Examples Example 1 In this example, there will be no output sent to the browser before the loop is finished. If buffer was set to False, then it would write a line to the browser every time it went through the loop. <%response.Buffer=true%> <% for i=1 to 100 response.write(i & " ") next %> Example 2 <%response.Buffer=true%>

I write some text, but I will control when the text will be sent to the browser.

The text is not sent yet. I hold it back!

OK, let it go!
<%response.Flush%> Example 3 <%response.Buffer=true%>

This is some text I want to send to the user.

No, I changed my mind. I want to clear the text.
<%response.Clear%> ASP CacheControl Property The CacheControl property sets whether a proxy server can cache the output generated by ASP or not. By default, a proxy server will not keep a cache copy. Syntax response.CacheControl[=control_header] Parameter Description control_header A cache control header that can be set to "Public" or "Private". Private is default and indicates that only private caches may cache this page. Proxy servers will not cache pages with this setting. Public indicates public caches. Proxy servers will cache pages with this setting. Examples <%response.CacheControl="Public"%> or <%response.CacheControl="Private"%> ASP Charset Property The Charset property appends the name of a character-set to the content-type header in the Response object. Default character set is ISO-LATIN-1. Note: This property will accept any string, regardless of whether it is a valid character set or not, for the name. Syntax response.Charset(charsetname) Parameter Description charsetname A string that specifies a character set for the page Examples If an ASP page has no Charset property set, the content-type header would be: content-type:text/html If we included the Charset property: <%response.Charset="ISO-8859-1"%> the content-type header would be: content-type:text/html; charset=ISO-8859-1 ASP ContentType Property ________________________________________ The ContentType property sets the HTTP content type for the response object. Syntax response.ContentType[=contenttype] Parameter Description contenttype A string describing the content type. For a full list of content types, see your browser documentation or the HTTP specification. Examples If an ASP page has no ContentType property set, the default content-type header would be: content-type:text/html Some other common ContentType values: <%response.ContentType="text/HTML"%> <%response.ContentType="image/GIF"%> <%response.ContentType="image/JPEG"%> <%response.ContentType="text/plain"%> <%response.ContentType="image/JPEG"%> This example will open an Excel spreadsheet in a browser (if the user has Excel installed): <%response.ContentType="application/vnd.ms-excel"%>
1 2 3 4
5 6 7 8
ASP Expires Property The Expires property sets how long (in minutes) a page will be cached on a browser before it expires. If a user returns to the same page before it expires, the cached version is displayed. Syntax response.Expires[=number] Parameter Description number The time in minutes before the page expires Examples Example 1 The following code indicates that the page will never be cached: <%response.Expires=-1%> Example 2 The following code indicates that the page will expire after 1440 minutes (24 hours): <%response.Expires=1440%> ASP ExpiresAbsolute Property ________________________________________ The ExpiresAbsolute property sets a date and time when a cached page on a browser will expire. If a user returns to the same page before this date/time, the cached version is displayed. Syntax response.ExpiresAbsolute[=[date][time]] Parameter Description date Specifies the date on which the page will expire. If this parameter is not specified, the page will expire at the specified time on the day that the script is run. time Specifies the time at which the page will expire. If this parameter is not specified, the page will expire at midnight of the specified day. Examples The following code indicates that the page will expire at 4:00 PM on October 11, 2009: <%response.ExpiresAbsolute=#October 11,2009 16:00:00#%> ASP IsClientConnected Property ________________________________________ The IsClientConnected property indicates if the client has disconnected from the server. Syntax response.IsClientConnected Examples <% If response.IsClientConnected=true then response.write("The user is still connected!") else response.write("The user is not connected!") end if %> ASP PICS Property ________________________________________ The PICS property appends a value to the PICS label response header. Note: This property will accept any string value, regardless of whether it is a valid PICS label or not. What is PICS? The PICS (Platform for Internet Content Selection) rating system is used to rate the content in a web site. It looks something like this: PICS-1.1 "http://www.rsac.org/ratingsv01.html" by "your@name.com" for "http://www.somesite.com" on "2002.10.05T02:15-0800" r (n 0 s 0 v 0 l 0) Part Description PICS-1.1 PICS version number "http://www.rsac.org/ratingsv01.html" Rating organization by "your@name.com" Author of the label for "http://www.somesite.com" The URL or the document that has been rated on "2002.10.05T02:15-0800" Expiration date r (n 0 s 0 v 0 l 0) Rating One of the most popular rating system is RSACi (Recreational Software Advisory Council on the Internet). RSACi rating system uses four categories: violence, nudity, sex, and language. A number between 0 to 4 is assigned to each category. 0 means that the page does not contain any potentially offensive content and 4 means that the page contains the highest levels of potentially offensive content. Level Violence Rating Nudity Rating Sex Rating Language Rating 0 None of the below or sports related None of the below None of the below or innocent kissing; romance None of the below 1 Injury to human being Revealing attire Passionate kissing Mild expletives 2 Destruction of realistic objects Partial nudity Clothed sexual touching Moderate expletives or profanity 3 Aggressive violence or death to humans Frontal nudity Non-explicit sexual acts Strong language or hate speech 4 Rape or wanton, gratuitous violence Frontal nudity (qualifying as provocative display) Explicit sexual acts or sex crimes Crude, vulgar language or extreme hate speech There are two ways you can obtain rating for your site. You can either rate your site yourself or use a rating provider, like RSACi. They'll ask you fill out some questions. After filling out the questions, you will get the rating label for your site. Microsoft IE 3.0 and above and Netscape 4.5 and above support the content ratings. You can set the ratings in IE 5, by selecting Tools and Internet Options. Select the Content tab and click the Enable. When the rating exceeds the defined levels the Content Advisor will block the site. You can set the ratings in Netscape 4.7, by selecting Help and NetWatch. We can use the META tag or the response.PICS property to add a rating to our site. Syntax response.PICS(picslabel) Parameter Description picslabel A properly formatted PICS label Examples For an ASP file that includes: Note: Because PICS labels contain quotes, you must replace quotes with " & chr(34) & ". <% response.PICS("(PICS-1.1 by " & chr(34) & "your@name.com" & chr(34) & " for " & chr(34) & "http://www.somesite.com" & chr(34) & " on " & chr(34) & "2002.10.05T02:15-0800" & chr(34) & " r (n 2 s 0 v 1 l 2))") %> the following header is added: PICS-label:(PICS-1.1 by "your@name.com" for "http://www.somesite.com" on "2002.10.05T02:15-0800" r (n 2 s 0 v 1 l 2)) ASP Status Property ________________________________________ The Status property specifies the value of the status line returned by the server. Tip: Use this property to modify the status line returned by the server. Syntax response.Status=statusdescription Parameter Description statusdescription A three-digit number and a description of that code, like 404 Not Found. Note: Status values are defined in the HTTP specification. Examples <% ip=request.ServerVariables("REMOTE_ADDR") if ip<>"194.248.333.500" then response.Status="401 Unauthorized" response.Write(response.Status) response.End end if %> Methods: ASP AddHeader Method ________________________________________ The AddHeader method adds a new HTTP header and a value to the HTTP response. Note: Once a header has been added, it cannot be removed. Note: In IIS 4.0 you have to call this method before any output is sent to the browser. In IIS 5.0 you can call the AddHeader method at any point in the script, as long as it precedes any calls to the response.Flush method. Syntax response.AddHeader name,value Parameter Description name Required. The name of the new header variable (cannot contain underscores) value Required. The initial value of the new header variable ________________________________________ Examples <%Response.AddHeader "WARNING","Error message text"%> ASP AppendToLog Method ________________________________________ The AppendToLog method adds a string to the end of server log entry for this request. You can call this method multiple times in a script. Each time it is called it will append the specified string to the log entry. Syntax response.AppendToLog string Parameter Description string Required. The text to append to the log file (cannot contain any comma characters) ________________________________________ Examples <%Response.AppendToLog "My log message"%> ASP BinaryWrite Method ________________________________________ The BinaryWrite method writes data directly to the output without any character conversion. Tip: This method is used to write image data (BLOB) from a database to a browser. Syntax response.BinaryWrite data Parameter Description data Required. The binary information to be sent ________________________________________ Example If you have an object that generates an array of bytes, you can use BinaryWrite to send the bytes to an application: <% Set objBinaryGen=Server.CreateObject("MyComponents.BinaryGenerator") pic=objBinaryGen.MakePicture response.BinaryWrite pic %> ________________________________________ ASP Clear Method ________________________________________ The Clear method clears any buffered HTML output. Note: This method does not clear the response headers, only the response body. Note: If response.Buffer is false, this method will cause a run-time error. Syntax response.Clear Examples <% response.Buffer=true %>

This is some text I want to send to the user.

No, I changed my mind. I want to clear the text.
<% response.Clear %> Output: (nothing) ASP End Method ________________________________________ The End method stops processing a script, and returns the current result. Note: This method will flush the buffer if Response.Buffer has been set to true. If you do not want to return any output to the user, you should call Response.Clear first. Syntax Response.End Examples

I am writing some text. This text will never be <% Response.End %> finished! It's too late to write more!
Output: I am writing some text. This text will never be ASP Flush Method ________________________________________ The Flush method sends buffered HTML output immediately. Note: If response.Buffer is false, this method will cause a run-time error. Syntax Response.Flush Example <% Response.Buffer=true %>

I write some text, but I will control when the text will be sent to the browser.

The text is not sent yet. I hold it back!

OK, let it go!
<% Response.Flush %> Output: I write some text, but I will control when the text will be sent to the browser. The text is not sent yet. I hold it back! OK, let it go! ASP Redirect Method ____________________________________

ASP Sending e-mail with CDOSYS CDOSYS is a built-in component in ASP. This component is used to send e-mails with ASP

. ________________________________________ Sending e-mail with CDOSYS CDO (Collaboration Data Objects) is a Microsoft technology that is designed to simplify the creation of messaging applications. CDOSYS is a built-in component in ASP. We will show you how to use this component to send e-mail with ASP. How about CDONTs? Microsoft has discontinued the use of CDONTs on Windows 2000, Windows XP and Windows 2003. If you have used CDONTs in your ASP applications, you should update the code and use the new CDO technology. Examples using CDOSYS Sending a text e-mail: <% Set myMail=CreateObject("CDO.Message") myMail.Subject="Sending email with CDO" myMail.From="mymail@mydomain.com" myMail.To="someone@somedomain.com" myMail.TextBody="This is a message." myMail.Send set myMail=nothing %> Sending a text e-mail with Bcc and CC fields: <% Set myMail=CreateObject("CDO.Message") myMail.Subject="Sending email with CDO" myMail.From="mymail@mydomain.com" myMail.To="someone@somedomain.com" myMail.Bcc="someoneelse@somedomain.com" myMail.Cc="someoneelse2@somedomain.com" myMail.TextBody="This is a message." myMail.Send set myMail=nothing %> Sending an HTML e-mail: <% Set myMail=CreateObject("CDO.Message") myMail.Subject="Sending email with CDO" myMail.From="mymail@mydomain.com" myMail.To="someone@somedomain.com" myMail.HTMLBody = " This is a message. " myMail.Send set myMail=nothing %> Sending an HTML e-mail that sends a webpage from a website: <% Set myMail=CreateObject("CDO.Message") myMail.Subject="Sending email with CDO" myMail.From="mymail@mydomain.com" myMail.To="someone@somedomain.com" myMail.CreateMHTMLBody "http://www.w3schools.com/asp/" myMail.Send set myMail=nothing %> Sending an HTML e-mail that sends a webpage from a file on your computer: <% Set myMail=CreateObject("CDO.Message") myMail.Subject="Sending email with CDO" myMail.From="mymail@mydomain.com" myMail.To="someone@somedomain.com" myMail.CreateMHTMLBody "file://c:/mydocuments/test.htm" myMail.Send set myMail=nothing %> Sending a text e-mail with an Attachment: <% Set myMail=CreateObject("CDO.Message") myMail.Subject="Sending email with CDO" myMail.From="mymail@mydomain.com" myMail.To="someone@somedomain.com" myMail.TextBody="This is a message." myMail.AddAttachment "c:\mydocuments\test.txt" myMail.Send set myMail=nothing %> Sending a text e-mail using a remote server: <% Set myMail=CreateObject("CDO.Message") myMail.Subject="Sending email with CDO" myMail.From="mymail@mydomain.com" myMail.To="someone@somedomain.com" myMail.TextBody="This is a message." myMail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2 'Name or IP of remote SMTP server myMail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.server.com" 'Server port myMail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25 myMail.Configuration.Fields.Update myMail.Send set myMail=nothing %> II ASP Objects 1)ASP Response Object The ASP Response object is used to send output to the user from the server.

Events in Global.asa with asp

In Global.asa you can tell the application and session objects what to do when the application/session starts and what to do when the application/session ends. The code for this is placed in event handlers. The Global.asa file can contain four types of events: Application_OnStart - Occurs when the FIRST user calls the first page in an ASP application. This event occurs after the Web server is restarted or after the Global.asa file is edited. The "Session_OnStart" event occurs immediately after this event. Session_OnStart - This event occurs EVERY time a NEW user requests his or her first page in the ASP application. Session_OnEnd - This event occurs EVERY time a user ends a session. A user-session ends after a page has not been requested by the user for a specified time (by default this is 20 minutes). Application_OnEnd - This event occurs after the LAST user has ended the session. Typically, this event occurs when a Web server stops. This procedure is used to clean up settings after the Application stops, like delete records or write information to text files. A Global.asa file could look something like this: Note: Because we cannot use the ASP script delimiters (<% and %>) to insert scripts in the Global.asa file, we put subroutines inside an HTML Global.asa can also be used to control page access. The example below shows how to redirect every new visitor to another page, in this case to a page called "newpage.asp": And you can include functions in the Global.asa file. In the example below the Application_OnStart subroutine occurs when the Web server starts. Then the Application_OnStart subroutine calls another subroutine named "getcustomers". The "getcustomers" subroutine opens a database and retrieves a record set from the "customers" table. The record set is assigned to an array, where it can be accessed from any ASP page without querying the database: ________________________________________ Global.asa Example In this example we will create a Global.asa file that counts the number of current visitors. • The Application_OnStart sets the Application variable "visitors" to 0 when the server starts • The Session_OnStart subroutine adds one to the variable "visitors" every time a new visitor arrives • The Session_OnEnd subroutine subtracts one from "visitors" each time this subroutine is triggered The Global.asa file: To display the number of current visitors in an ASP file:

There are <%response.write(Application("visitors"))%> online now!

Tips and Notes In the sections above we have used the file extension ".inc" for included files

. Notice that if a user tries to browse an INC file directly, its content will be displayed. If your included file contains confidential information or information you do not want any users to see, it is better to use an ASP extension. The source code in an ASP file will not be visible after the interpretation. An included file can also include other files, and one ASP file can include the same file more than once. Important: Included files are processed and inserted before the scripts are executed. The following script will NOT work because ASP executes the #include directive before it assigns a value to the variable: <% fname="header.inc" %> You cannot open or close a script delimiter in an INC file. The following script will NOT work: <% For i = 1 To n Next %> But this script will work: <% For i = 1 to n %> <% Next %> 11.ASP The Global.asa file The Global.asa file The Global.asa file is an optional file that can contain declarations of objects, variables, and methods that can be accessed by every page in an ASP application. All valid browser scripts (JavaScript, VBScript, JScript, PerlScript, etc.) can be used within Global.asa. The Global.asa file can contain only the following: • Application events • Session events • declarations • TypeLibrary declarations • the #include directive Note: The Global.asa file must be stored in the root directory of the ASP application, and each application can only have one Global.asa file.

How to Use the #include Directive Here is a file called "mypage.asp": Words of Wisdom:

The time is:

Here is the "wisdom.inc" file: "One should never increase, beyond what is necessary, the number of entities required to explain anything." Here is the "time.inc" file: <% Response.Write(Time) %> If you look at the source code in a browser, it will look something like this:
Words of Wisdom:

"One should never increase, beyond what is necessary, the number of entities required to explain anything."
The time is:

11:33:42 AM
Syntax for Including Files To include a file in an ASP page, place the #include directive inside comment tags: or The Virtual Keyword Use the virtual keyword to indicate a path beginning with a virtual directory. If a file named "header.inc" resides in a virtual directory named /html, the following line would insert the contents of "header.inc": The File Keyword Use the file keyword to indicate a relative path. A relative path begins with the directory that contains the including file. If you have a file in the html directory, and the file "header.inc" resides in html\headers, the following line would insert "header.inc" in your file: Note that the path to the included file (headers\header.inc) is relative to the including file. If the file containing this #include statement is not in the html directory, the statement will not work.

The Session object of active server pages

When you are working with an application on your computer, you open it, do some changes and then you close it. This is much like a Session. The computer knows who you are. It knows when you open the application and when you close it. However, on the internet there is one problem: the web server does not know who you are and what you do, because the HTTP address doesn't maintain state.
ASP solves this problem by creating a unique cookie for each user. The cookie is sent to the user's computer and it contains information that identifies the user. This interface is called the Session object.
The Session object stores information about, or change settings for a user session.
Variables stored in a Session object hold information about one single user, and are available to all pages in one application. Common information stored in session variables are name, id, and preferences. The server creates a new Session object for each new user, and destroys the Session object when the session expires.

When does a Session Start?
A session starts when:
• A new user requests an ASP file, and the Global.asa file includes a Session_OnStart procedure
• A value is stored in a Session variable
• A user requests an ASP file, and the Global.asa file uses the tag to instantiate an object with session scope
When does a Session End? A session ends if a user has not requested or refreshed a page in the application for a specified period. By default, this is 20 minutes. If you want to set a timeout interval that is shorter or longer than the default, use the Timeout property. The example below sets a timeout interval of 5 minutes: <% Session.Timeout=5 %> Use the Abandon method to end a session immediately: <% Session.Abandon %> Note: The main problem with sessions is WHEN they should end. We do not know if the user's last request was the final one or not. So we do not know how long we should keep the session "alive". Waiting too long for an idle session uses up resources on the server, but if the session is deleted too soon the user has to start all over again because the server has deleted all the information. Finding the right timeout interval can be difficult! Tip: Only store SMALL amounts of data in session variables!
Store and Retrieve Session Variables The most important thing about the Session object is that you can store variables in it. The example below will set the Session variable username to "Donald Duck" and the Session variable age to "50": <% Session("username")="Donald Duck" Session("age")=50 %> When the value is stored in a session variable it can be reached from ANY page in the ASP application: Welcome <%Response.Write(Session("username"))%> The line above returns: "Welcome Donald Duck". You can also store user preferences in the Session object, and then access that preference to choose what page to return to the user. The example below specifies a text-only version of the page if the user has a low screen resolution: <%If Session("screenres")="low" Then%> This is the text version of the page <%Else%> This is the multimedia version of the page <%End If%>
Remove Session Variables The Contents collection contains all session variables. It is possible to remove a session variable with the Remove method. The example below removes the session variable "sale" if the value of the session variable "age" is lower than 18: <% If Session.Contents("age")<18 then Session.Contents.Remove("sale") End If %> To remove all variables in a session, use the RemoveAll method: <% Session.Contents.RemoveAll() %>
Loop Through the Contents Collection The Contents collection contains all session variables. You can loop through the Contents collection, to see what's stored in it: <% Session("username")="Donald Duck" Session("age")=50 dim i For Each i in Session.Contents Response.Write(i & " ") Next %> Result: username age If you do not know the number of items in the Contents collection, you can use the Count property: <% dim i dim j j=Session.Contents.Count Response.Write("Session variables: " & j) For i=1 to j Response.Write(Session.Contents(i) & " ") Next %> Result: Session variables: 2 Donald Duck 50
Loop Through the StaticObjects Collection You can loop through the StaticObjects collection, to see the values of all objects stored in the Session object: <% dim i For Each i in Session.StaticObjects Response.Write(i & " ") Next %> 9. ASP Application Object A group of ASP files that work together to perform some purpose is called an application.
Application Object An application on the Web may consists of several ASP files that work together to perform some purpose. The Application object is used to tie these files together. The Application object is used to store and access variables from any page, just like the Session object. The difference is that ALL users share ONE Application object (with Sessions there is ONE Session object for EACH user). The Application object holds information that will be used by many pages in the application (like database connection information). The information can be accessed from any page. The information can also be changed in one place, and the changes will automatically be reflected on all pages.
Store and Retrieve Application Variables Application variables can be accessed and changed by any page in an application. You can create Application variables in "Global.asa" like this: In the example above we have created two Application variables: "vartime" and "users". You can access the value of an Application variable like this: There are <% Response.Write(Application("users")) %> active connections.
Loop Through the Contents Collection The Contents collection contains all application variables. You can loop through the Contents collection, to see what's stored in it: <% dim i For Each i in Application.Contents Response.Write(i & " ") Next %> If you do not know the number of items in the Contents collection, you can use the Count property: <% dim i dim j j=Application.Contents.Count For i=1 to j Response.Write(Application.Contents(i) & " ") Next %> Loop Through the StaticObjects Collection You can loop through the StaticObjects collection, to see the values of all objects stored in the Application object: <% dim i For Each i in Application.StaticObjects Response.Write(i & " ") Next %>
Lock and Unlock You can lock an application with the "Lock" method. When an application is locked, the users cannot change the Application variables (other than the one currently accessing it). You can unlock an application with the "Unlock" method. This method removes the lock from the Application variable: <% Application.Lock 'do some application object operations Application.Unlock %> 10.ASP Including Files The #include Directive You can insert the content of one ASP file into another ASP file before the server executes it, with the #include directive. The #include directive is used to create functions, headers, footers, or elements that will be reused on multiple pages.