Notes
Get em jsp
Content of the notes (1)
Page 1
Primeiro vem o arquivo jsp com o formulário
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form action="newjsp1.jsp">
Nome:<br>
<input type="text" name="name" placeholder="insira">
<br>
Sobrenome:<br>
<input type="text" name="last" placeholder="insira">
<br>
Qual é a melhor série do mundo?<br>
<input type="text" name="serie" placeholder="insira"><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
Depois vem o get das informações
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Resultado</h1>
<% String nome = request.getParameter("name");
String sobrenome = request.getParameter("last");
String serie = request.getParameter("serie");
%>
<%=(nome)
%>
<%=(sobrenome)
%><br>
<% if (nome == "Gabriel"){
out.print("Você é o gabriel");
}else{
out.print("Seu nome é diferente"+"<br>");
}
if ( (serie.equals("game of thrones")) || (serie.equals("Game of thrones")) ){
out.print("<br>"+"<br>"+"Você escolheu Game of thrones e está mais do que correta"+"<br>");
}
else
{
out.print("<br>"+"Você escolheu "+serie+" e não está certo." );}
%>
</body>
</html>