Muestra las diferencias entre dos versiones de la página.
Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previa | ||
dad2:formulario_servlets [2024/02/06 11:50] – thejuanvisu | dad2:formulario_servlets [2024/02/06 11:56] (actual) – thejuanvisu | ||
---|---|---|---|
Línea 25: | Línea 25: | ||
< | < | ||
{{: | {{: | ||
+ | </ | ||
+ | |||
+ | En nuestro servlet tendremos el siguiente código: | ||
+ | <code java> | ||
+ | package com.organizacion.servlets; | ||
+ | |||
+ | import jakarta.servlet.ServletException; | ||
+ | import jakarta.servlet.annotation.WebServlet; | ||
+ | import jakarta.servlet.http.HttpServlet; | ||
+ | import jakarta.servlet.http.HttpServletRequest; | ||
+ | import jakarta.servlet.http.HttpServletResponse; | ||
+ | import java.io.IOException; | ||
+ | import java.util.Enumeration; | ||
+ | |||
+ | /** | ||
+ | * Servlet implementation class Hola_Mundo | ||
+ | */ | ||
+ | public class Hola_Mundo extends HttpServlet { | ||
+ | private static final long serialVersionUID = 1L; | ||
+ | |||
+ | /** | ||
+ | * @see HttpServlet# | ||
+ | */ | ||
+ | public Hola_Mundo() { | ||
+ | super(); | ||
+ | // TODO Auto-generated constructor stub | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * @see HttpServlet# | ||
+ | */ | ||
+ | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, | ||
+ | // TODO Auto-generated method stub | ||
+ | |||
+ | String paramName =""; | ||
+ | response.getWriter().append("< | ||
+ | |||
+ | for(Enumeration< | ||
+ | paramName=params.nextElement(); | ||
+ | response.getWriter().append("< | ||
+ | } | ||
+ | |||
+ | response.getWriter().append("</ | ||
+ | |||
+ | |||
+ | // | ||
+ | // | ||
+ | // | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * @see HttpServlet# | ||
+ | */ | ||
+ | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, | ||
+ | // TODO Auto-generated method stub | ||
+ | doGet(request, | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | Cuando rellenemos el campo con un texto y le demos al botón se nos mostrará la siguiente página: | ||
+ | < | ||
+ | {{: | ||
</ | </ |