08_Servlet - CSI 3540 Structures, techniques et normes du...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSI 3540 Structures, techniques et normes du Web Tuesday, February 9, 2010 Objectif: Introduction la programmation ct serveur Introduction aux Servlets Lectures: Web Technologies (2007) 6 Pages 307322 Programmation ct serveur : Servlets Tuesday, February 9, 2010 Plan 1. Survol des Servlet 2. Redfnir doGet() et doPost() 3. Dveloppement dune application Web 1. Ant (asant) 2. War 3. GlassFish Tuesday, February 9, 2010 Servlet Internet Client Serveur Serveur W eb Servlet Requte HTTP Rponse HTTP Tuesday, February 9, 2010 Squence 1/4 Le serveur Web reoit une requte dun agent utilisateur Le dcodage de lURI : exemple, le chemin dbute par /servlet Internet Client Serveur Serveur W eb Servlet Requte HTTP Rponse HTTP Tuesday, February 9, 2010 Confguration httpd.conf LoadModule jk2_module libexec/mod_jk2.so workers2.properities [channel.socket:localhost:8009] port=8009 host=127 .0.0.1 [ajp13:localhost:8009]channel=channel.socket:localhost:8009 [uri:/servlet/*] worker=ajp13:localhost:8009 Tuesday, February 9, 2010 Squence 2/4 Le serveur Web fait un appel de mthode du Servlet Passe en paramtre deux objets modlisant la requte et la rponse : HttpServletRequest et HttpServletResponse Ces objets sont dFnis par Java Servlet API Internet Client Serveur Serveur W eb Servlet Requte HTTP Rponse HTTP Tuesday, February 9, 2010 Squence 3/4 Le Servlet excute un traitement Typiquement, le Servlet construira une page HTML quil sauvegardera dans lobjet HttpServletResponse Le Servlet peut aussi ajouter lobjet rponse des informations quil souhaite transmettre au client (via le serveur Web) Internet Client Serveur Serveur W eb Servlet Requte HTTP Rponse HTTP Tuesday, February 9, 2010 Squence 4/4 Le serveur Web gnre un message HTTP rponse , partir des informations sauvegardes dans lobjet HttpServletResponse , quil envoie lagent utilisateur Internet Client Serveur Serveur W eb Servlet Requte HTTP Rponse HTTP Tuesday, February 9, 2010 Quelle heure est-il ? Problme Concevoir une application ( Servlet ) qui afFche la date et l heure chaque appel Les pages seront certainement gnres dynamiquement Tuesday, February 9, 2010 import java.io. *; import javax.servlet. * ; import javax.servlet.http. * ; import java.util.Date ; public class GetTime extends HttpServlet { public void doGet ( HttpServletRequest requete , HttpServletResponse reponse ) throws ServletException , IOException { reponse.setContentType( "text/html; charset=\"UTF-8\"" ); PrintWriter doc = reponse.getWriter() ; doc.println( "<!DOCTYPE html" ) ; // ......
View Full Document

Page1 / 102

08_Servlet - CSI 3540 Structures, techniques et normes du...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online