(1) For example,
<body bgcolor="#ccccff">
<% if Request.QueryString("num")
<> "" then
Dim Result
Result = 0
for i = 1 to Request.QueryString("num").Count
Result = Result + CLng(Request.QueryString("num")(i))
next ' i
Response.write "Sum of numbers: " & Result
else
Response.write "No numbers supplied!"
end if
%>
</body>
(2) For example,
H2.box {
font-style: italic;
border: 3px #000000 dashed;
padding: 10px;
}
(3) For example,
package Fall2001;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class t2aq3 extends HttpServlet {
public void doGet(HttpServletRequest
req, HttpServletResponse res)
throws ServletException, IOException {
// Set the Content-Type
header
res.setContentType("text/html");
// Return early if this
is a HEAD method.
if (req.getMethod().equals("HEAD"))
return;
// get the parameter
value of num.
String str = req.getParameter("inStr");
String result = "";
if (str == null) {
result = "<form>String: <input type=\"text\" name=\"inStr\" size=\"20\">"
+ "<p><input
type=\"submit\"></form>";
}
else {
result = "The length of \"" + str + "\" is " + str.length() + ".";
}
// Print result.
PrintWriter out = res.getWriter();
out.println("<HTML>");
out.println("<HEAD><TITLE>String
Length</TITLE></HEAD>");
out.println("<BODY>");
out.println("<H2 STYLE='color:blue'>String
length</H2><P>");
out.println(result);
out.println("</BODY></HTML>");
}
}
(4) For example,
<% option explicit %>
<!-- Suggested Solution to Final
Examination of CSCI 4230.1 Question 2,
Fall 2001.
No error handling.
-->
<html>
<head>
<title>Faculty Update</title>
<body bgcolor="#ccccff">
<%
Dim DSN
DSN = "yuep"
' Get SSNum
' Open database connection.
Dim conn
Set conn = Server.CreateObject("adodb.connection")
conn.open DSN
Dim sql
sql = "select FacultyId, FacultyLastName,
FacultyFirstName, FacultyEmail from t2q4"
' Response.write "sql => " & sql &
"<br>"
Dim ResultRS
set ResultRS = conn.execute(sql)
if (ResultRS.eof) then
Response.write "<h2>Sorry, There
is no faculty record to edit " & SSNum & ".</h2>"
Response.End
end if
%>
<h2>Edit Faculty Records</h2>
<%
do while not ResultRS.eof
Response.write "<form action=""processUpdate.asp"">"
& _
ResultRS.fields("FacultyFirstName")
& " " & ResultRS.fields("FacultyLastName") & _
"<input
type=""hidden"" name =""FacultyId"" value=""" & _
ResultRS.fields("FacultyId")
& """><br>Email: " & _
"<input
type=""text"" name=""Email"" value=""" & _
ResultRS.fields("FacultyEmail")
& _
"""> <input
type=""submit"" value=""Update Email!""></form>"
ResultRS.movenext
loop
%>
</body>
</html>