Skip to content
Snippets Groups Projects
Commit e6a8d77d authored by Gwendal Margely's avatar Gwendal Margely :alembic:
Browse files

ÃMoving to maven + major changes to Servlet + proper integration of jackson ton dependencies

parent 9b98cc85
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ package Servlets; ...@@ -4,7 +4,7 @@ package Servlets;
import DAO.IngredientDAO; import DAO.IngredientDAO;
import POJO.Ingredient; import POJO.Ingredient;
import com.fasterxml.jackson.*; import com.fasterxml.jackson.databind.ObjectMapper;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet; import javax.servlet.annotation.WebServlet;
...@@ -44,7 +44,7 @@ public class IngredientServlet extends HttpServlet { ...@@ -44,7 +44,7 @@ public class IngredientServlet extends HttpServlet {
// Get ingredient by id // Get ingredient by id
try { try {
int id = Integer.parseInt(pathParts[1]); int id = Integer.parseInt(pathParts[1]);
Ingredient ingredient = ingredientDAO.getIngredient(id); Ingredient ingredient = IngredientDAO.getIngredient(id);
if (ingredient != null) { if (ingredient != null) {
resp.setContentType("application/json"); resp.setContentType("application/json");
resp.getWriter().write(objectMapper.writeValueAsString(ingredient)); resp.getWriter().write(objectMapper.writeValueAsString(ingredient));
...@@ -63,7 +63,7 @@ public class IngredientServlet extends HttpServlet { ...@@ -63,7 +63,7 @@ public class IngredientServlet extends HttpServlet {
// Get ingredient name by id // Get ingredient name by id
try { try {
int id = Integer.parseInt(pathParts[1]); int id = Integer.parseInt(pathParts[1]);
Ingredient ingredient = ingredientDAO.getIngredient(id); Ingredient ingredient = IngredientDAO.getIngredient(id);
if (ingredient != null) { if (ingredient != null) {
resp.setContentType("application/json"); resp.setContentType("application/json");
resp.getWriter().write(objectMapper.writeValueAsString(ingredient.getName())); resp.getWriter().write(objectMapper.writeValueAsString(ingredient.getName()));
......
File added
File added
File added
File added
File added
File added
File added
File added
File added
pom.xml 0 → 100644
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>saedelbemargelypizzeria</groupId>
<artifactId>pizzeria-del-sae</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.5</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>WEB-INF/src</sourceDirectory>
<testSourceDirectory>WEB-INF/test</testSourceDirectory>
</build>
</project>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment