Java/JSP/String — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 07:10, 1 июня 2010
Creating a String
<HTML>
<HEAD>
<TITLE>Creating a String</TITLE>
</HEAD>
<BODY>
<H1>Creating a String</H1>
<%
String greeting = "Hello from JSP!";
out.println(greeting);
%>
</BODY>
</HTML>
Getting String Length
<HTML>
<HEAD>
<TITLE>Getting String Length</TITLE>
</HEAD>
<BODY>
<H1>Getting String Length</H1>
<%
String s1 = "Hello from JSP!";
out.println("\"" + s1 + "\"" + " is " + s1.length()
+ " characters long.");
%>
</BODY>
</HTML>
String array
<%--
Copyright (c) 2002 by Phil Hanna
All rights reserved.
You may study, use, modify, and distribute this
software for any purpose provided that this
copyright notice appears in all copies.
This software is provided without warranty
either expressed or implied.
--%>
<%@ page session="false" %>
<%
String[] colors = {"red", "green", "blue"};
for (int i = 0; i < colors.length; i++) {
out.print("<p>" + colors[i] + "</p>");
}
%>