File tree 4 files changed +72
-6
lines changed
java/ejemplos/servlet/curso 4 files changed +72
-6
lines changed Original file line number Diff line number Diff line change 56
56
</configuration >
57
57
</plugin >
58
58
</plugins >
59
+ <resources >
60
+ <resource >
61
+ <directory >src/main/webapp/css</directory >
62
+ </resource >
63
+ </resources >
59
64
</build >
60
65
</project >
Original file line number Diff line number Diff line change @@ -19,11 +19,19 @@ protected void doGet(HttpServletRequest request,
19
19
20
20
// send HTML page to client
21
21
out .println ("<html>" );
22
- out .println ("<head><title>Ejemplo HTML desde Servlet</title></head>" );
22
+ out .println ("<head><title>Ejemplo HTML desde Servlet</title><link rel= \" stylesheet \" href= \" css/estilos.css \" >< /head>" );
23
23
out .println ("<body>" );
24
- out .println ("<h1>Ejemplo Servlet</h1>" );
25
- out .println ("<p>Este es un ejemplo en el curso de Java para generar HTML desde un Servlet.</p>" );
26
- out .println ("<p><a href=\" /myServlet2\" >Vamos al otro Servlet</a></p>" );
24
+ out .println ("<h1 class=\" greetings\" >Java Servlets Tutorial</h1>" );
25
+ // out.println("<p>Este es un ejemplo en el curso de Java para generar HTML desde un Servlet.</p>");
26
+ // out.println("<p><a href=\"/myServlet2\">Vamos al otro Servlet</a></p>");
27
+ out .println ("<div class=\" form-container\" >" );
28
+ out .println ("<form action=\" /myServlet2\" >" );
29
+ out .println ("<label for=\" nombre\" >Nombre:</label><br>" );
30
+ out .println ("<input type=\" text\" id=\" nombre\" name=\" nombre\" placeholder=\" María\" autofocus><br>" );
31
+ out .println ("<input type=\" submit\" class=\" btn-submit\" value=\" Entrar\" >" );
32
+ out .println ("</form>" );
33
+ out .println ("</div" );
34
+
27
35
out .println ("</body></html>" );
28
36
}
29
37
Original file line number Diff line number Diff line change @@ -17,11 +17,21 @@ protected void doGet(HttpServletRequest request,
17
17
response .setContentType ("text/html" );
18
18
PrintWriter out = response .getWriter ();
19
19
20
+ // leemos el valor del nombre enviado a través de la URL
21
+ String nombre = request .getParameter ("nombre" );
22
+
20
23
// send HTML page to client
21
24
out .println ("<html>" );
22
- out .println ("<head><title>Ejemplo HTML desde Servlet</title></head>" );
25
+ out .println ("<head><title>Ejemplo HTML desde Servlet</title><link rel= \" stylesheet \" href= \" css/estilos.css \" >< /head>" );
23
26
out .println ("<body>" );
24
- out .println ("<h1>Bienvenido!!</h1>" );
27
+ out .println ("<div class=\" main-container\" >" );
28
+ // Modificamos la salida para añadir el saludo personalizado
29
+ out .println ("<h1>Bienvenid@, " + nombre + "!!</h1>" );
30
+ out .println ("</div" );
31
+
32
+ out .println ("<p><a class=\" backlink\" href=\" /myServlet\" >Volver</a></p>" );
33
+
34
+ out .println ("</body></html>" );
25
35
}
26
36
27
37
}
Original file line number Diff line number Diff line change
1
+ body {
2
+ background-color : # b0c4de ;
3
+ }
4
+
5
+ h1 {
6
+ text-align : center;
7
+ }
8
+
9
+ .greetings {
10
+ padding : 25% 0 0 ;
11
+ }
12
+
13
+ .form-container , .main-container {
14
+ display : flex;
15
+ flex-direction : row;
16
+ justify-content : space-around;
17
+ }
18
+
19
+ .main-container {
20
+ margin-top : 20% ;
21
+ }
22
+
23
+ input [name = "nombre" ] {
24
+ margin : 3px 0 15px ;
25
+ }
26
+
27
+ .btn-submit {
28
+ padding : 4px 11px ;
29
+ border-radius : 10% ;
30
+ background-color : lightgrey;
31
+ }
32
+
33
+ .btn-submit : hover {
34
+ padding : 4px 11px ;
35
+ cursor : pointer;
36
+ border-radius : 10% ;
37
+ background-color : darkgrey;
38
+ box-shadow : 5px 6px 3px # 888888 ;
39
+ }
40
+
41
+ .backlink {
42
+ margin : 6% ;
43
+ }
You can’t perform that action at this time.
0 commit comments