9. Linguagens de script sobre CGI my $your_age_html = ""; my @your_age_opts = ("Please select","Under 18","18-35","35-55"); foreach my $your_age_option ( @your_age_opts ) { $your_age_html .= "<option value=amp;quot;$your_age_optionamp;quot;"; $your_age_html .= " selected" if ( $your_age_option eq $your_age ); $your_age_html .= ">$your_age_option</option>"; }
10. Framework sobre CGI <html> <body> Welcome <?php echo $_POST["fname"]; ?>!<br /> You are <?php echo $_POST["age"]; ?> years old. </body> </html>
11. Final dos anos 90 public class HelloWorld extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); out.println("<form action=amp;quot;http://somesite.com/prog/adduser" method="post"> "); //... } }
12. Final dos anos 90 <%@ page import=java.util.Date %> <%@ page import=java.lang.String %> <% String msg = ""; String mesString = request.getParameter("mesNasceu"); int mes = Integer.parseInt(mesString); Date dateNow = new Date(); int monthNow = dateNow.getMonth() + 1; mes -= monthNow; if (mes == 1) msg = "Falta apenas "+ mes +" mês para o seu aniversário."; if (mes == -1) msg = "Seu aniversário foi no mês passado"; if (mes > 1) msg = "Faltam "+ mes +" meses para o seu aniversário."; if (mes == 0) msg = "Oba... estamos no mês do seu aniversário."; else if (mes < 1) { mes *= -1; msg = "Seu aniversário foi a "+ mes +" meses atrás."; } %> <html><body> <h3><%= msg %></h3> <br><br><br> <a href="Javascript:history.back(-1)">voltar</a> </body></html>
13. Início dos anos 2000 <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:c="http://java.sun.com/jsp/jstl/core" version="2.0"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>c:forEach Example</title> </head> <body> <table> <c:forEach var="person" items="${people.people}"> <tr> <td>${person.name}</td> <td>${person.age}</td> <td>${person.height}</td> </tr> </c:forEach> </table> </body> </html>