(1) For example,
body { font-family: "Verdana";
background: URL("back.jpeg");
}
.box { border: 1px #000000 solid; padding:
5px;
height: auto; width: 300px; float: right;}
(2)
CreatedTime.jsp:
<body>
<jsp:useBean id="ct"
class="CreatedTimeBean" />
Using direct method call, the created time
is
<%= ct.getCreatedTime()
%>.
<p>
Using getProperty, it is
<jsp:getProperty name="ct" property="CreatedTime"
/>
</body>
CreatedTimeBean.java:
import java.util.*;
public class CreatedTimeBean {
private String createdTime
= new Date().toString();
public String getCreatedTime()
{
return createdTime;
}
}
(3)
<?xml version="1.0"?>
<quotations>
<quotation>
<author name="yue"
/>
<content>
IBM + X = IBM, MSFT >
IBM => MSFT + X > IBM.
</content>
</quotation>
<quotation>
<content>
Both ASP and JSP use <%
and %>.
</content>
</quotation>
</quotations>
(4) For example,
<html>
<head>
<title>Question 4, CSCI 4230.1, Spring
2001</title>
<link rel="stylesheet" type="text/css"
href="t2aq4.css">
</head>
<%
' Open database connection.
Dim conn
Set conn = Server.CreateObject("adodb.connection")
' DSN
conn.open "temp"
Dim sql
sql = "select Author, Quotation from quotations
"
Dim result
set result = conn.execute(sql)
if (not result.eof) then
%>
<body onLoad="nextQuote()">
<form name="f1">
<input type="text" maxlength="30" size="20"
name="author">:
<input type="text" maxlength="80" size="50"
name="quote">
<p>
<input type="button" value="Next Quote!"
onClick="nextQuote()">
</form>
<script language="javascript">
Quotes = new Array(
<% Dim JustStarted
JustStarted = true
do while (not result.eof)
Dim quotation
Dim author
author = result.fields("Author")
author = Replace(author,"\","\\")
author = Replace(author,"""","\""")
quotation = result.fields("Quotation")
quotation = Replace(quotation,"\","\\")
quotation = Replace(quotation,"""","\""")
if (not JustStarted) then
response.write ", "
end if
response.write """" & author & """, """ & quotation & """"
JustStarted = false
result.movenext
loop
%>
);
Quotes.count = Quotes.length-1;
function nextQuote() {
Quotes.count += 2;
if (Quotes.count >= Quotes.length)
{
Quotes.count = 0;
}
document.f1.author.value
= Quotes[Quotes.count];
document.f1.quote.value
= Quotes[Quotes.count+1];
}
</script>
<%
else
%>
<body>
Sorry, no quotation.
<%
end if
conn.execute(sql)
conn.close
%>
</body>
</html>
(5) For example,
<%
for each key in Request.QueryString
if Request.QueryString(key).count <= 1 then
Response.write (key & " => " & Request.QueryString(key) & "<br>")
else
for i = 1 to Request.QueryString(key).count
Response.write (key & "[" & i &"] => " & Request.QueryString(key)(i)
& "<br>")
next ' i
end if
next
%>