domingo, 27 de enero de 2013

Variables

Variable cadena


<%
String v1="esta es mi variable";
%>
<html>
<body>
Valor de la cadena : <%=v1%>
</body>
</html>


Variable entera


<%
int v2=5;
%>
<html>
<body>
Valor de la cadena : <%=v2%>
</body>
</html>

Variable flotante

<%
float v3=567.345f;
%>
<html>
<body>
Valor de la cadena : <%=v3%>
</body>
</html>

Variable booleana

<%
boolean v4=false;
%>
<html>
<body>
    <%
    if(v4==true)
    {
      out.print("Esto es verdadero");
    }
    else
    {
      out.print("Esto es falso");
    }
    %>
</body>
</html>

Variable fecha



<%@ page import="java.util.*" %>
<%@ page import="java.text.DateFormat" %>
<%@ page import="java.text.SimpleDateFormat" %>
<HTML>
<BODY>
<%
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date v5 = new Date();
%>
Esta es la fecha : <%= dateFormat.format(v5) %>
</BODY>
</HTML>

Variable array

<%
String[] v6=new String[4];
v6[0]="bob";
v6[1]="riche";
v6[2]="jacky";
v6[3]="rosy";
%>
<html>
<body>
    <%  
      out.print("Elemento de array :"+v6[2]);
    %>
</body>
</html>









No hay comentarios:

Publicar un comentario