Java Tutorial/JSP/String
Версия от 17:44, 31 мая 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>
Use for loop to display 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>");
}
%>