sysrep:tp1
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
sysrep:tp1 [2012/11/14 10:53] – created orel | sysrep:tp1 [2024/03/18 15:06] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== TP1 ====== | + | ====== TP1 : Rappels Web ====== |
+ | |||
+ | ==== Documentations utiles==== | ||
+ | |||
+ | * http:// | ||
+ | * http:// | ||
+ | * http:// | ||
+ | * http:// | ||
+ | |||
+ | ==== Installation d'un serveur Web Apache Tomcat ==== | ||
+ | |||
+ | ==Installation sur votre compte (ou dans /tmp)...== | ||
+ | |||
+ | Télécharger l' | ||
+ | |||
+ | |||
+ | wget http:// | ||
+ | |||
+ | |||
+ | Décompressez l' | ||
+ | |||
+ | |||
+ | tar xvzf apache-tomcat-6.0.20.tar.gz | ||
+ | |||
+ | |||
+ | Configurez votre environnement pour Apache/ | ||
+ | |||
+ | export CATALINA_HOME=< | ||
+ | |||
+ | Puis lancer le serveur Web Tomcat (à l' | ||
+ | |||
+ | < | ||
+ | |||
+ | Vous pouvez ensuite consulter http:// | ||
+ | |||
+ | ==Configuration avançée== | ||
+ | |||
+ | Pour changer le port 8080, vous pouvez editer le fichier < | ||
+ | |||
+ | < | ||
+ | |||
+ | Il faut maintenant ajouter un administrateur au serveur Web Tomcat en ajoutant au fichier de configuration < | ||
+ | |||
+ | <code xml> | ||
+ | <role rolename=" | ||
+ | <role rolename=" | ||
+ | <user username=" | ||
+ | </ | ||
+ | |||
+ | Relancer le serveur Web. Démarrer l' | ||
+ | ==== Serveur Web et Servlet ==== | ||
+ | |||
+ | Un peu d'aide pour la suite : http:// | ||
+ | |||
+ | ==Page Web HelloWorld== | ||
+ | |||
+ | Par défaut, il faut ajouter les ressources web dans le répertoire < | ||
+ | |||
+ | Ajouter l' | ||
+ | |||
+ | ==Servlet Hello World== | ||
+ | |||
+ | Toujours dans le sous-répertoire test/, nous allons ajouter une servlet. Ecrire une servlet " | ||
+ | |||
+ | <code java HelloServlet.java> | ||
+ | import java.io.*; | ||
+ | import javax.servlet.*; | ||
+ | import javax.servlet.http.*; | ||
+ | |||
+ | public class HelloServlet extends HttpServlet { | ||
+ | |||
+ | public void doGet(HttpServletRequest request, HttpServletResponse response) | ||
+ | throws IOException, | ||
+ | { | ||
+ | response.setContentType(" | ||
+ | PrintWriter out = response.getWriter(); | ||
+ | out.println("< | ||
+ | /* ... */ | ||
+ | out.println("</ | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Pour compiler votre servlet, utilisez la ligne de commande ci-dessous : | ||
+ | |||
+ | $ javac -cp " | ||
+ | |||
+ | |||
+ | Il faut maintenant créer un répertoire WEB-INF/ dans test/ et déplacer le fichier HelloServlet.class dans le sous-répertoire WEB-INF/ | ||
+ | |||
+ | Pour rendre votre servlet accessible à l'URL suivante : http:// | ||
+ | |||
+ | il faut ajoutez un fichier web.xml dans WEB-INF/ avec les informations suivantes : | ||
+ | |||
+ | <code xml web.xml> | ||
+ | <?xml version=" | ||
+ | |||
+ | < | ||
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==Utilisation de Paramètres== | ||
+ | |||
+ | Ecrire maintenant une servlet " | ||
+ | |||
+ | http:// | ||
+ | |||
+ | Mettre maintenant en place une page HTML " | ||
+ | |||
+ | http:// | ||
+ | |||
+ | ==Un exemple de JSP (Java Server Page)== | ||
+ | |||
+ | Ecrire maintenant la JSP HelloWorld.jsp, | ||
+ | |||
+ | http:// | ||
+ | |||
+ | ==Mise en place de HTTPS== | ||
+ | |||
+ | En vous aidant de l'aide http:// | ||
+ | |||
+ | https:// | ||
sysrep/tp1.1352890392.txt.gz · Last modified: 2024/03/18 15:05 (external edit)