implementato esercizio studenti con collegamento da client via interfaccia remota
This commit is contained in:
57
servlet/Servletexercise1.java
Normal file
57
servlet/Servletexercise1.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package servlet;
|
||||
|
||||
import test3_persistence.store_class;
|
||||
import test3_persistence.test_class;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Giovanni on 25/04/2015.
|
||||
*/
|
||||
|
||||
@WebServlet(name = "Servletexercise1")
|
||||
public class Servletexercise1 extends HttpServlet {
|
||||
|
||||
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
try (PrintWriter out = response.getWriter()) {
|
||||
/* TODO output your page here. */
|
||||
|
||||
out.println("<!DOCTYPE html>");
|
||||
out.println("<html>");
|
||||
out.println("<head>");
|
||||
out.println("<title>Servlet xg</title>");
|
||||
out.println("</head>");
|
||||
out.println("<body>");
|
||||
out.println("<h1>Servlet xg at " + request.getContextPath() + "</h1>");
|
||||
|
||||
|
||||
|
||||
out.println("</body>");
|
||||
out.println("</html>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,10 @@ public class Servlettest2 extends HttpServlet {
|
||||
class_with_builtin_constraints class_with_builtin_constraints;
|
||||
|
||||
|
||||
@Inject
|
||||
class_test_method class_test_method;
|
||||
|
||||
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
try (PrintWriter out = response.getWriter()) {
|
||||
@@ -61,6 +65,10 @@ public class Servlettest2 extends HttpServlet {
|
||||
out.println("<h1>Servlet xg at " + request.getContextPath() + "</h1>");
|
||||
|
||||
|
||||
///////////////// check null return
|
||||
//class_test_method.test_method();
|
||||
//out.println("Test Null without validator");
|
||||
//out.println("<br>");
|
||||
|
||||
|
||||
///////////////// entire class validation
|
||||
@@ -123,7 +131,7 @@ public class Servlettest2 extends HttpServlet {
|
||||
|
||||
|
||||
out.println("<br>");
|
||||
//////////////// check single property
|
||||
//////////////// check single property without make an instance of the object
|
||||
Set<ConstraintViolation<class_with_builtin_constraints>> violations7 = validator.validateValue(class_with_builtin_constraints.class, "title", "aabb");
|
||||
if (violations7.size() > 0) out.println("error"); else out.println("tutto ok");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user