Initial commit
This commit is contained in:
58
src/main/java/pr/tp/web/HelloServlet.java
Normal file
58
src/main/java/pr/tp/web/HelloServlet.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package pr.tp.web;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@WebServlet("/hello")
|
||||
public class HelloServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void init(ServletConfig config) throws ServletException {
|
||||
|
||||
Enumeration<String> e2 = config.getInitParameterNames();
|
||||
while (e2.hasMoreElements()) {
|
||||
String key = (String) e2.nextElement();
|
||||
String value = getInitParameter(key);
|
||||
System.out.println(" " + key + " = " + value);
|
||||
}
|
||||
|
||||
|
||||
super.init(config);
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
PrintWriter out = response.getWriter();
|
||||
out.println("<html>");
|
||||
out.println("<head><title>Hello World</title></head>");
|
||||
out.println("<body>");
|
||||
String nom = request.getParameter("nom");
|
||||
if(nom!=null) {
|
||||
out.println("Hello "+ nom);
|
||||
}else {
|
||||
out.println("Hello World");
|
||||
}
|
||||
|
||||
ServletContext context = getServletContext();
|
||||
Enumeration<String> e = context.getInitParameterNames();
|
||||
while (e.hasMoreElements()) {
|
||||
String key = (String) e.nextElement();
|
||||
Object value = context.getInitParameter(key);
|
||||
System.out.println(" " + key + " = " + value);
|
||||
}
|
||||
|
||||
|
||||
out.println("</body>");
|
||||
out.println("</html>");
|
||||
}
|
||||
|
||||
}
|
||||
7
src/main/webapp/WEB-INF/web.xml
Normal file
7
src/main/webapp/WEB-INF/web.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<!DOCTYPE web-app PUBLIC
|
||||
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
||||
"http://java.sun.com/dtd/web-app_2_3.dtd" >
|
||||
|
||||
<web-app>
|
||||
<display-name>Archetype Created Web Application</display-name>
|
||||
</web-app>
|
||||
16
src/main/webapp/index.jsp
Normal file
16
src/main/webapp/index.jsp
Normal file
@@ -0,0 +1,16 @@
|
||||
<%@ page import="java.util.Date" %>
|
||||
<html>
|
||||
<body>
|
||||
<h2>Hello World!</h2>
|
||||
<p> Il est <%= new Date() %> </p>
|
||||
|
||||
<pre>
|
||||
|
||||
La balise pre
|
||||
|
||||
permet de conserver les retours à la ligne.
|
||||
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user