Java/JSP/String

Материал из Java эксперт
Версия от 18:01, 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>





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>");
   }
%>