Skip to content

Instantly share code, notes, and snippets.

View yostane's full-sized avatar

Yassine Benabbas yostane

View GitHub Profile
import org.eclipse.microprofile.config.inject.ConfigProperty;
import javax.inject.Inject;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
@Path("sample")
public class SampleResource {
@Inject
import java.io.Serializable;
public class TestJsonRessource {
private static final long serialVersionUID = 4254739092263227552L;
private String name;
private String age;
public String getName() {
return name;
}
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/titans")
public Response getTitans() {
// src: https://attaque-des-titans.fandom.com/fr/wiki/Titans
String titans[] = {"Titan Colossal", "Titan Cuirassé", "Titan Assaillant", "Titan Féminin", "Titan Mâchoire",
"Titan Bestial",
"Titan Charrette",
"Titan Marteau d'Armes", "Titan Originel"};
return Response.ok(titans).build();
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
<title>Première page JSP</title>
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
<link rel="manifest" href="site.webmanifest">
@yostane
yostane / index.jsp
Last active January 24, 2021 21:24
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
<html>
<head>
<title>Première page JSP</title>
</head>
<body>
<p>
<%
out.print("Votre addresse IP est 🕵️: " + request.getRemoteAddr());
@yostane
yostane / web.xml
Last active January 24, 2021 21:03
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<mainClass>com.mycompany.app.App</mainClass>
</configuration>
</plugin>
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.WindowConstants;
public class SimpleGui {
private static void createAndShowGUI() {
// Create and set up the window.
JFrame frame = new JFrame("HelloWorldSwing");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
@yostane
yostane / SimpleServer.java
Created January 3, 2021 12:06
Java simple HTTP server
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
public class SimpleServer {
Tutu, Tintin, Pikachu, Sangoku