Arquivo: webapps\seunome\teste.jsp |
<!-- String Texto; for (int x=0; x <= 6; x++ ) { |
Arquivo: teste.html |
<HTML> <HEAD> <TITLE>Formulário para Soma</TITLE> </HEAD> <BODY> <FORM action="soma.jsp" method="post"> <INPUT name='vl1' size='5' value='2'/> + <INPUT name='vl2' size='5' value='2'/> <INPUT name='submit' type='submit' value='Soma' /> </FORM> </BODY> </HTML> |
Arquivo: soma.jsp |
<html> <head> <title>Soma</title> </head> <body> <% int vl1=Integer.parseInt(request.getParameter("vl1")); int vl2=Integer.parseInt(request.getParameter("vl2")); int soma=vl1+vl2; %> Resultado = <b> <%=soma%> </b> </body> </html> |
Arquivo: teste.jsp |
<html> <head> <title>Arquivo externo</title> </head> <body> <jsp:forward page="arquivo_externo.jsp" /> </body> </html> |
Arquivo: arquivo_externo.jsp |
<% String jsp = "JSP ok!!"; %> <h1> <% out.println(jsp); %> </h1> |
Arquivo: semana.jsp |
<%@page import="java.util.Calendar" %> int DiaDaSemana=DataToda.get(Calendar.DAY_OF_WEEK); switch(DiaDaSemana) { case 1: Texto = "Domingo"; break; |
Arquivo: teste.html |
<html> <head> <title>Untitled Document</title> </head> <body> <a href="teste.jsp?Parametro1=Valor1&Parametro2=Valor2">Teste</a> </body> </html> |
Arquivo: teste.jsp |
<html> <head> <title>Untitled Document</title> </head> <body> <% String Var1 = request.getParameter("Parametro1"); String Var2 = request.getParameter("Parametro2"); out.println(Var1 + " " + Var2); %> </body> </html> |
Arquivo: index.jsp |
<%@page import="java.net.*" %> <% String assinatura = "algumacoisa"; String cookieName = "assinatura" ; Cookie cookie = new Cookie(cookieName, assinatura ); cookie.setMaxAge(360); // 1 hora response.addCookie(cookie); %> <html> <head> <title>Cookies</title> </head> <body> <a href="recebido.jsp">recebido.jsp </a> </body> </html> |
Arquivo: recebido.jsp |
<%@page import="java.net.*" %> |
Arquivo: funcao.jsp |
<html> <head> <title>Untitled Document</title> </head> <body> <p><% out.println(funcao_x()); %></p> </body> <%! public String funcao_x(){ return "Hello Java"; } %> </html> |
Arquivo: objeto.java |
<html> public String getCodigo(){ |