Servlets: Exemples d’utiliastion des paramètre des URLs

response.getOutputStream();
    String fileName = request.getParameter("file");
    out.println("<html>");
    out.println("<head>");
    out.println("<title>W
import java.io.IOException;
 
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
public class ShowFile extends HttpServlet {
 
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
 
    ServletOutputStream out = response.getOutputStream();
    // lire le paramètre
    String msg = request.getParameter("message");
 
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Bienvenu</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h2>Voici votre message</h2>");
    out.println(msg);
    out.println("</body>");
    out.println("</html>");
    out.close();
 
  }
 
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    doGet(request, response);
  }
}
 
           
       

Be the first to leave a comment. Don’t be shy.

Join the Discussion

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>