repo
stringclasses
1k values
file_url
stringlengths
96
373
file_path
stringlengths
11
294
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
6 values
commit_sha
stringclasses
1k values
retrieved_at
stringdate
2026-01-04 14:45:56
2026-01-04 18:30:23
truncated
bool
2 classes
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/repository/EmployeeRepository.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/repository/EmployeeRepository.java
package com.baeldung.jaxws.server.repository; import java.util.List; import com.baeldung.jaxws.server.bottomup.exception.EmployeeAlreadyExists; import com.baeldung.jaxws.server.bottomup.exception.EmployeeNotFound; import com.baeldung.jaxws.server.bottomup.model.Employee; public interface EmployeeRepository { List<Employee> getAllEmployees(); Employee getEmployee(int id) throws EmployeeNotFound; Employee updateEmployee(int id, String name) throws EmployeeNotFound; boolean deleteEmployee(int id) throws EmployeeNotFound; Employee addEmployee(int id, String name) throws EmployeeAlreadyExists; int count(); }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/config/EmployeeServicePublisher.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/config/EmployeeServicePublisher.java
package com.baeldung.jaxws.server.config; import javax.xml.ws.Endpoint; import com.baeldung.jaxws.server.bottomup.EmployeeServiceImpl; import com.baeldung.jaxws.server.topdown.EmployeeServiceTopDownImpl; public class EmployeeServicePublisher { public static void main(String[] args) { Endpoint.publish("http://localhost:8080/employeeservicetopdown", new EmployeeServiceTopDownImpl()); Endpoint.publish("http://localhost:8080/employeeservice", new EmployeeServiceImpl()); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/EmployeeServiceImpl.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/EmployeeServiceImpl.java
package com.baeldung.jaxws.server.bottomup; import java.util.List; import javax.inject.Inject; import javax.jws.WebMethod; import javax.jws.WebService; import com.baeldung.jaxws.server.bottomup.exception.EmployeeAlreadyExists; import com.baeldung.jaxws.server.bottomup.exception.EmployeeNotFound; import com.baeldung.jaxws.server.bottomup.model.Employee; import com.baeldung.jaxws.server.repository.EmployeeRepository; @WebService(serviceName = "EmployeeService", endpointInterface = "com.baeldung.jaxws.server.bottomup.EmployeeService") public class EmployeeServiceImpl implements EmployeeService { @Inject private EmployeeRepository employeeRepositoryImpl; @WebMethod public Employee getEmployee(int id) throws EmployeeNotFound { return employeeRepositoryImpl.getEmployee(id); } @WebMethod public Employee updateEmployee(int id, String name) throws EmployeeNotFound { return employeeRepositoryImpl.updateEmployee(id, name); } @WebMethod public boolean deleteEmployee(int id) throws EmployeeNotFound { return employeeRepositoryImpl.deleteEmployee(id); } @WebMethod public Employee addEmployee(int id, String name) throws EmployeeAlreadyExists { return employeeRepositoryImpl.addEmployee(id, name); } @WebMethod public int countEmployees() { return employeeRepositoryImpl.count(); } @WebMethod public List<Employee> getAllEmployees() { return employeeRepositoryImpl.getAllEmployees(); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/EmployeeService.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/EmployeeService.java
package com.baeldung.jaxws.server.bottomup; import java.util.List; import javax.jws.WebMethod; import javax.jws.WebService; import com.baeldung.jaxws.server.bottomup.exception.EmployeeAlreadyExists; import com.baeldung.jaxws.server.bottomup.exception.EmployeeNotFound; import com.baeldung.jaxws.server.bottomup.model.Employee; @WebService public interface EmployeeService { @WebMethod Employee getEmployee(int id) throws EmployeeNotFound; @WebMethod Employee updateEmployee(int id, String name) throws EmployeeNotFound; @WebMethod boolean deleteEmployee(int id) throws EmployeeNotFound; @WebMethod Employee addEmployee(int id, String name) throws EmployeeAlreadyExists; @WebMethod int countEmployees(); @WebMethod List<Employee> getAllEmployees(); }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/model/Employee.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/model/Employee.java
package com.baeldung.jaxws.server.bottomup.model; public class Employee { private int id; private String firstName; public Employee() { } public Employee(int id, String firstName) { this.id = id; this.firstName = firstName; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/exception/EmployeeAlreadyExists.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/exception/EmployeeAlreadyExists.java
package com.baeldung.jaxws.server.bottomup.exception; import javax.xml.ws.WebFault; @WebFault public class EmployeeAlreadyExists extends Exception { public EmployeeAlreadyExists() { super("This employee already exists"); } public EmployeeAlreadyExists(String str) { super(str); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/exception/EmployeeNotFound.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/server/bottomup/exception/EmployeeNotFound.java
package com.baeldung.jaxws.server.bottomup.exception; import javax.xml.ws.WebFault; @WebFault public class EmployeeNotFound extends Exception { public EmployeeNotFound() { super("The specified employee does not exist"); } public EmployeeNotFound(String str) { super(str); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/DeleteEmployee.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/DeleteEmployee.java
package com.baeldung.jaxws.client; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for deleteEmployee complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="deleteEmployee"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="arg0" type="{http://www.w3.org/2001/XMLSchema}int"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "deleteEmployee", propOrder = { "arg0" }) public class DeleteEmployee { protected int arg0; /** * Gets the value of the arg0 property. * */ public int getArg0() { return arg0; } /** * Sets the value of the arg0 property. * */ public void setArg0(int value) { this.arg0 = value; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeServiceClient.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeServiceClient.java
package com.baeldung.jaxws.client; import java.net.URI; import java.net.URL; import java.util.List; public class EmployeeServiceClient { public static void main(String[] args) throws Exception { URL url = new URI("http://localhost:8080/employeeservice?wsdl").toURL(); EmployeeService_Service employeeService_Service = new EmployeeService_Service(url); EmployeeService employeeServiceProxy = employeeService_Service.getEmployeeServiceImplPort(); List<Employee> allEmployees = employeeServiceProxy.getAllEmployees(); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/Employee.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/Employee.java
package com.baeldung.jaxws.client; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for employee complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="employee"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="firstName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> * &lt;element name="id" type="{http://www.w3.org/2001/XMLSchema}int"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "employee", propOrder = { "firstName", "id" }) public class Employee { protected String firstName; protected int id; /** * Gets the value of the firstName property. * * @return * possible object is * {@link String } * */ public String getFirstName() { return firstName; } /** * Sets the value of the firstName property. * * @param value * allowed object is * {@link String } * */ public void setFirstName(String value) { this.firstName = value; } /** * Gets the value of the id property. * */ public int getId() { return id; } /** * Sets the value of the id property. * */ public void setId(int value) { this.id = value; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/GetEmployee.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/GetEmployee.java
package com.baeldung.jaxws.client; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for getEmployee complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="getEmployee"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="arg0" type="{http://www.w3.org/2001/XMLSchema}int"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "getEmployee", propOrder = { "arg0" }) public class GetEmployee { protected int arg0; /** * Gets the value of the arg0 property. * */ public int getArg0() { return arg0; } /** * Sets the value of the arg0 property. * */ public void setArg0(int value) { this.arg0 = value; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/CountEmployees.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/CountEmployees.java
package com.baeldung.jaxws.client; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for countEmployees complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="countEmployees"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "countEmployees") public class CountEmployees { }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/CountEmployeesResponse.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/CountEmployeesResponse.java
package com.baeldung.jaxws.client; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for countEmployeesResponse complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="countEmployeesResponse"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="return" type="{http://www.w3.org/2001/XMLSchema}int"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "countEmployeesResponse", propOrder = { "_return" }) public class CountEmployeesResponse { @XmlElement(name = "return") protected int _return; /** * Gets the value of the return property. * */ public int getReturn() { return _return; } /** * Sets the value of the return property. * */ public void setReturn(int value) { this._return = value; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeAlreadyExists_Exception.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeAlreadyExists_Exception.java
package com.baeldung.jaxws.client; import javax.xml.ws.WebFault; /** * This class was generated by the JAX-WS RI. * JAX-WS RI 2.2.9-b130926.1035 * Generated source version: 2.2 * */ @WebFault(name = "EmployeeAlreadyExists", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/") public class EmployeeAlreadyExists_Exception extends Exception { /** * Java type that goes as soapenv:Fault detail element. * */ private EmployeeAlreadyExists faultInfo; /** * * @param faultInfo * @param message */ public EmployeeAlreadyExists_Exception(String message, EmployeeAlreadyExists faultInfo) { super(message); this.faultInfo = faultInfo; } /** * * @param faultInfo * @param cause * @param message */ public EmployeeAlreadyExists_Exception(String message, EmployeeAlreadyExists faultInfo, Throwable cause) { super(message, cause); this.faultInfo = faultInfo; } /** * * @return * returns fault bean: com.baeldung.jaxws.client.EmployeeAlreadyExists */ public EmployeeAlreadyExists getFaultInfo() { return faultInfo; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/package-info.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/package-info.java
@javax.xml.bind.annotation.XmlSchema(namespace = "http://bottomup.server.jaxws.baeldung.com/") package com.baeldung.jaxws.client;
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeNotFound_Exception.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeNotFound_Exception.java
package com.baeldung.jaxws.client; import javax.xml.ws.WebFault; /** * This class was generated by the JAX-WS RI. * JAX-WS RI 2.2.9-b130926.1035 * Generated source version: 2.2 * */ @WebFault(name = "EmployeeNotFound", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/") public class EmployeeNotFound_Exception extends Exception { /** * Java type that goes as soapenv:Fault detail element. * */ private EmployeeNotFound faultInfo; /** * * @param faultInfo * @param message */ public EmployeeNotFound_Exception(String message, EmployeeNotFound faultInfo) { super(message); this.faultInfo = faultInfo; } /** * * @param faultInfo * @param cause * @param message */ public EmployeeNotFound_Exception(String message, EmployeeNotFound faultInfo, Throwable cause) { super(message, cause); this.faultInfo = faultInfo; } /** * * @return * returns fault bean: com.baeldung.jaxws.client.EmployeeNotFound */ public EmployeeNotFound getFaultInfo() { return faultInfo; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/GetAllEmployees.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/GetAllEmployees.java
package com.baeldung.jaxws.client; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for getAllEmployees complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="getAllEmployees"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "getAllEmployees") public class GetAllEmployees { }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/GetAllEmployeesResponse.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/GetAllEmployeesResponse.java
package com.baeldung.jaxws.client; import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for getAllEmployeesResponse complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="getAllEmployeesResponse"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="return" type="{http://bottomup.server.jaxws.baeldung.com/}employee" maxOccurs="unbounded" minOccurs="0"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "getAllEmployeesResponse", propOrder = { "_return" }) public class GetAllEmployeesResponse { @XmlElement(name = "return") protected List<Employee> _return; /** * Gets the value of the return property. * * <p> * This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a <CODE>set</CODE> method for the return property. * * <p> * For example, to add a new item, do as follows: * <pre> * getReturn().add(newItem); * </pre> * * * <p> * Objects of the following type(s) are allowed in the list * {@link Employee } * * */ public List<Employee> getReturn() { if (_return == null) { _return = new ArrayList<Employee>(); } return this._return; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/ObjectFactory.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/ObjectFactory.java
package com.baeldung.jaxws.client; import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlElementDecl; import javax.xml.bind.annotation.XmlRegistry; import javax.xml.namespace.QName; /** * This object contains factory methods for each * Java content interface and Java element interface * generated in the com.baeldung.jaxws.client package. * <p>An ObjectFactory allows you to programatically * construct new instances of the Java representation * for XML content. The Java representation of XML * content can consist of schema derived interfaces * and classes representing the binding of schema * type definitions, element declarations and model * groups. Factory methods for each of these are * provided in this class. * */ @XmlRegistry public class ObjectFactory { private final static QName _AddEmployeeResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "addEmployeeResponse"); private final static QName _EmployeeAlreadyExists_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeAlreadyExists"); private final static QName _GetEmployeeResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "getEmployeeResponse"); private final static QName _EmployeeNotFound_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeNotFound"); private final static QName _CountEmployees_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "countEmployees"); private final static QName _UpdateEmployee_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "updateEmployee"); private final static QName _DeleteEmployeeResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "deleteEmployeeResponse"); private final static QName _GetAllEmployeesResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "getAllEmployeesResponse"); private final static QName _DeleteEmployee_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "deleteEmployee"); private final static QName _UpdateEmployeeResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "updateEmployeeResponse"); private final static QName _AddEmployee_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "addEmployee"); private final static QName _GetAllEmployees_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "getAllEmployees"); private final static QName _CountEmployeesResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "countEmployeesResponse"); private final static QName _GetEmployee_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "getEmployee"); /** * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.baeldung.jaxws.client * */ public ObjectFactory() { } /** * Create an instance of {@link EmployeeNotFound } * */ public EmployeeNotFound createEmployeeNotFound() { return new EmployeeNotFound(); } /** * Create an instance of {@link CountEmployees } * */ public CountEmployees createCountEmployees() { return new CountEmployees(); } /** * Create an instance of {@link AddEmployeeResponse } * */ public AddEmployeeResponse createAddEmployeeResponse() { return new AddEmployeeResponse(); } /** * Create an instance of {@link EmployeeAlreadyExists } * */ public EmployeeAlreadyExists createEmployeeAlreadyExists() { return new EmployeeAlreadyExists(); } /** * Create an instance of {@link GetEmployeeResponse } * */ public GetEmployeeResponse createGetEmployeeResponse() { return new GetEmployeeResponse(); } /** * Create an instance of {@link DeleteEmployeeResponse } * */ public DeleteEmployeeResponse createDeleteEmployeeResponse() { return new DeleteEmployeeResponse(); } /** * Create an instance of {@link GetAllEmployeesResponse } * */ public GetAllEmployeesResponse createGetAllEmployeesResponse() { return new GetAllEmployeesResponse(); } /** * Create an instance of {@link UpdateEmployee } * */ public UpdateEmployee createUpdateEmployee() { return new UpdateEmployee(); } /** * Create an instance of {@link CountEmployeesResponse } * */ public CountEmployeesResponse createCountEmployeesResponse() { return new CountEmployeesResponse(); } /** * Create an instance of {@link GetEmployee } * */ public GetEmployee createGetEmployee() { return new GetEmployee(); } /** * Create an instance of {@link DeleteEmployee } * */ public DeleteEmployee createDeleteEmployee() { return new DeleteEmployee(); } /** * Create an instance of {@link UpdateEmployeeResponse } * */ public UpdateEmployeeResponse createUpdateEmployeeResponse() { return new UpdateEmployeeResponse(); } /** * Create an instance of {@link AddEmployee } * */ public AddEmployee createAddEmployee() { return new AddEmployee(); } /** * Create an instance of {@link GetAllEmployees } * */ public GetAllEmployees createGetAllEmployees() { return new GetAllEmployees(); } /** * Create an instance of {@link Employee } * */ public Employee createEmployee() { return new Employee(); } /** * Create an instance of {@link JAXBElement }{@code <}{@link AddEmployeeResponse }{@code >}} * */ @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "addEmployeeResponse") public JAXBElement<AddEmployeeResponse> createAddEmployeeResponse(AddEmployeeResponse value) { return new JAXBElement<AddEmployeeResponse>(_AddEmployeeResponse_QNAME, AddEmployeeResponse.class, null, value); } /** * Create an instance of {@link JAXBElement }{@code <}{@link EmployeeAlreadyExists }{@code >}} * */ @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "EmployeeAlreadyExists") public JAXBElement<EmployeeAlreadyExists> createEmployeeAlreadyExists(EmployeeAlreadyExists value) { return new JAXBElement<EmployeeAlreadyExists>(_EmployeeAlreadyExists_QNAME, EmployeeAlreadyExists.class, null, value); } /** * Create an instance of {@link JAXBElement }{@code <}{@link GetEmployeeResponse }{@code >}} * */ @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "getEmployeeResponse") public JAXBElement<GetEmployeeResponse> createGetEmployeeResponse(GetEmployeeResponse value) { return new JAXBElement<GetEmployeeResponse>(_GetEmployeeResponse_QNAME, GetEmployeeResponse.class, null, value); } /** * Create an instance of {@link JAXBElement }{@code <}{@link EmployeeNotFound }{@code >}} * */ @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "EmployeeNotFound") public JAXBElement<EmployeeNotFound> createEmployeeNotFound(EmployeeNotFound value) { return new JAXBElement<EmployeeNotFound>(_EmployeeNotFound_QNAME, EmployeeNotFound.class, null, value); } /** * Create an instance of {@link JAXBElement }{@code <}{@link CountEmployees }{@code >}} * */ @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "countEmployees") public JAXBElement<CountEmployees> createCountEmployees(CountEmployees value) { return new JAXBElement<CountEmployees>(_CountEmployees_QNAME, CountEmployees.class, null, value); } /** * Create an instance of {@link JAXBElement }{@code <}{@link UpdateEmployee }{@code >}} * */ @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "updateEmployee") public JAXBElement<UpdateEmployee> createUpdateEmployee(UpdateEmployee value) { return new JAXBElement<UpdateEmployee>(_UpdateEmployee_QNAME, UpdateEmployee.class, null, value); } /** * Create an instance of {@link JAXBElement }{@code <}{@link DeleteEmployeeResponse }{@code >}} * */ @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "deleteEmployeeResponse") public JAXBElement<DeleteEmployeeResponse> createDeleteEmployeeResponse(DeleteEmployeeResponse value) { return new JAXBElement<DeleteEmployeeResponse>(_DeleteEmployeeResponse_QNAME, DeleteEmployeeResponse.class, null, value); } /** * Create an instance of {@link JAXBElement }{@code <}{@link GetAllEmployeesResponse }{@code >}} * */ @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "getAllEmployeesResponse") public JAXBElement<GetAllEmployeesResponse> createGetAllEmployeesResponse(GetAllEmployeesResponse value) { return new JAXBElement<GetAllEmployeesResponse>(_GetAllEmployeesResponse_QNAME, GetAllEmployeesResponse.class, null, value); } /** * Create an instance of {@link JAXBElement }{@code <}{@link DeleteEmployee }{@code >}} * */ @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "deleteEmployee") public JAXBElement<DeleteEmployee> createDeleteEmployee(DeleteEmployee value) { return new JAXBElement<DeleteEmployee>(_DeleteEmployee_QNAME, DeleteEmployee.class, null, value); } /** * Create an instance of {@link JAXBElement }{@code <}{@link UpdateEmployeeResponse }{@code >}} * */ @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "updateEmployeeResponse") public JAXBElement<UpdateEmployeeResponse> createUpdateEmployeeResponse(UpdateEmployeeResponse value) { return new JAXBElement<UpdateEmployeeResponse>(_UpdateEmployeeResponse_QNAME, UpdateEmployeeResponse.class, null, value); } /** * Create an instance of {@link JAXBElement }{@code <}{@link AddEmployee }{@code >}} * */ @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "addEmployee") public JAXBElement<AddEmployee> createAddEmployee(AddEmployee value) { return new JAXBElement<AddEmployee>(_AddEmployee_QNAME, AddEmployee.class, null, value); } /** * Create an instance of {@link JAXBElement }{@code <}{@link GetAllEmployees }{@code >}} * */ @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "getAllEmployees") public JAXBElement<GetAllEmployees> createGetAllEmployees(GetAllEmployees value) { return new JAXBElement<GetAllEmployees>(_GetAllEmployees_QNAME, GetAllEmployees.class, null, value); } /** * Create an instance of {@link JAXBElement }{@code <}{@link CountEmployeesResponse }{@code >}} * */ @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "countEmployeesResponse") public JAXBElement<CountEmployeesResponse> createCountEmployeesResponse(CountEmployeesResponse value) { return new JAXBElement<CountEmployeesResponse>(_CountEmployeesResponse_QNAME, CountEmployeesResponse.class, null, value); } /** * Create an instance of {@link JAXBElement }{@code <}{@link GetEmployee }{@code >}} * */ @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "getEmployee") public JAXBElement<GetEmployee> createGetEmployee(GetEmployee value) { return new JAXBElement<GetEmployee>(_GetEmployee_QNAME, GetEmployee.class, null, value); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/GetEmployeeResponse.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/GetEmployeeResponse.java
package com.baeldung.jaxws.client; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for getEmployeeResponse complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="getEmployeeResponse"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="return" type="{http://bottomup.server.jaxws.baeldung.com/}employee" minOccurs="0"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "getEmployeeResponse", propOrder = { "_return" }) public class GetEmployeeResponse { @XmlElement(name = "return") protected Employee _return; /** * Gets the value of the return property. * * @return * possible object is * {@link Employee } * */ public Employee getReturn() { return _return; } /** * Sets the value of the return property. * * @param value * allowed object is * {@link Employee } * */ public void setReturn(Employee value) { this._return = value; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/UpdateEmployeeResponse.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/UpdateEmployeeResponse.java
package com.baeldung.jaxws.client; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for updateEmployeeResponse complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="updateEmployeeResponse"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="return" type="{http://bottomup.server.jaxws.baeldung.com/}employee" minOccurs="0"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "updateEmployeeResponse", propOrder = { "_return" }) public class UpdateEmployeeResponse { @XmlElement(name = "return") protected Employee _return; /** * Gets the value of the return property. * * @return * possible object is * {@link Employee } * */ public Employee getReturn() { return _return; } /** * Sets the value of the return property. * * @param value * allowed object is * {@link Employee } * */ public void setReturn(Employee value) { this._return = value; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeAlreadyExists.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeAlreadyExists.java
package com.baeldung.jaxws.client; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for EmployeeAlreadyExists complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="EmployeeAlreadyExists"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="message" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "EmployeeAlreadyExists", propOrder = { "message" }) public class EmployeeAlreadyExists { protected String message; /** * Gets the value of the message property. * * @return * possible object is * {@link String } * */ public String getMessage() { return message; } /** * Sets the value of the message property. * * @param value * allowed object is * {@link String } * */ public void setMessage(String value) { this.message = value; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/UpdateEmployee.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/UpdateEmployee.java
package com.baeldung.jaxws.client; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for updateEmployee complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="updateEmployee"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="arg0" type="{http://www.w3.org/2001/XMLSchema}int"/> * &lt;element name="arg1" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "updateEmployee", propOrder = { "arg0", "arg1" }) public class UpdateEmployee { protected int arg0; protected String arg1; /** * Gets the value of the arg0 property. * */ public int getArg0() { return arg0; } /** * Sets the value of the arg0 property. * */ public void setArg0(int value) { this.arg0 = value; } /** * Gets the value of the arg1 property. * * @return * possible object is * {@link String } * */ public String getArg1() { return arg1; } /** * Sets the value of the arg1 property. * * @param value * allowed object is * {@link String } * */ public void setArg1(String value) { this.arg1 = value; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeNotFound.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeNotFound.java
package com.baeldung.jaxws.client; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for EmployeeNotFound complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="EmployeeNotFound"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="message" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "EmployeeNotFound", propOrder = { "message" }) public class EmployeeNotFound { protected String message; /** * Gets the value of the message property. * * @return * possible object is * {@link String } * */ public String getMessage() { return message; } /** * Sets the value of the message property. * * @param value * allowed object is * {@link String } * */ public void setMessage(String value) { this.message = value; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/DeleteEmployeeResponse.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/DeleteEmployeeResponse.java
package com.baeldung.jaxws.client; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for deleteEmployeeResponse complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="deleteEmployeeResponse"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="return" type="{http://www.w3.org/2001/XMLSchema}boolean"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "deleteEmployeeResponse", propOrder = { "_return" }) public class DeleteEmployeeResponse { @XmlElement(name = "return") protected boolean _return; /** * Gets the value of the return property. * */ public boolean isReturn() { return _return; } /** * Sets the value of the return property. * */ public void setReturn(boolean value) { this._return = value; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/AddEmployee.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/AddEmployee.java
package com.baeldung.jaxws.client; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for addEmployee complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="addEmployee"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="arg0" type="{http://www.w3.org/2001/XMLSchema}int"/> * &lt;element name="arg1" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "addEmployee", propOrder = { "arg0", "arg1" }) public class AddEmployee { protected int arg0; protected String arg1; /** * Gets the value of the arg0 property. * */ public int getArg0() { return arg0; } /** * Sets the value of the arg0 property. * */ public void setArg0(int value) { this.arg0 = value; } /** * Gets the value of the arg1 property. * * @return * possible object is * {@link String } * */ public String getArg1() { return arg1; } /** * Sets the value of the arg1 property. * * @param value * allowed object is * {@link String } * */ public void setArg1(String value) { this.arg1 = value; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeService.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeService.java
package com.baeldung.jaxws.client; import java.util.List; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebResult; import javax.jws.WebService; import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.ws.Action; import javax.xml.ws.FaultAction; import javax.xml.ws.RequestWrapper; import javax.xml.ws.ResponseWrapper; /** * This class was generated by the JAX-WS RI. * JAX-WS RI 2.2.9-b130926.1035 * Generated source version: 2.2 * */ @WebService(name = "EmployeeService", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/") @XmlSeeAlso({ ObjectFactory.class }) public interface EmployeeService { /** * * @param arg0 * @return * returns com.baeldung.jaxws.client.Employee * @throws EmployeeNotFound_Exception */ @WebMethod @WebResult(targetNamespace = "") @RequestWrapper(localName = "getEmployee", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.GetEmployee") @ResponseWrapper(localName = "getEmployeeResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.GetEmployeeResponse") @Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/getEmployeeRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/getEmployeeResponse", fault = { @FaultAction(className = EmployeeNotFound_Exception.class, value = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/getEmployee/Fault/EmployeeNotFound") }) public Employee getEmployee( @WebParam(name = "arg0", targetNamespace = "") int arg0) throws EmployeeNotFound_Exception ; /** * * @param arg1 * @param arg0 * @return * returns com.baeldung.jaxws.client.Employee * @throws EmployeeNotFound_Exception */ @WebMethod @WebResult(targetNamespace = "") @RequestWrapper(localName = "updateEmployee", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.UpdateEmployee") @ResponseWrapper(localName = "updateEmployeeResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.UpdateEmployeeResponse") @Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/updateEmployeeRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/updateEmployeeResponse", fault = { @FaultAction(className = EmployeeNotFound_Exception.class, value = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/updateEmployee/Fault/EmployeeNotFound") }) public Employee updateEmployee( @WebParam(name = "arg0", targetNamespace = "") int arg0, @WebParam(name = "arg1", targetNamespace = "") String arg1) throws EmployeeNotFound_Exception ; /** * * @return * returns java.util.List<com.baeldung.jaxws.client.Employee> */ @WebMethod @WebResult(targetNamespace = "") @RequestWrapper(localName = "getAllEmployees", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.GetAllEmployees") @ResponseWrapper(localName = "getAllEmployeesResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.GetAllEmployeesResponse") @Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/getAllEmployeesRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/getAllEmployeesResponse") public List<Employee> getAllEmployees(); /** * * @param arg0 * @return * returns boolean * @throws EmployeeNotFound_Exception */ @WebMethod @WebResult(targetNamespace = "") @RequestWrapper(localName = "deleteEmployee", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.DeleteEmployee") @ResponseWrapper(localName = "deleteEmployeeResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.DeleteEmployeeResponse") @Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/deleteEmployeeRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/deleteEmployeeResponse", fault = { @FaultAction(className = EmployeeNotFound_Exception.class, value = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/deleteEmployee/Fault/EmployeeNotFound") }) public boolean deleteEmployee( @WebParam(name = "arg0", targetNamespace = "") int arg0) throws EmployeeNotFound_Exception ; /** * * @param arg1 * @param arg0 * @return * returns com.baeldung.jaxws.client.Employee * @throws EmployeeAlreadyExists_Exception */ @WebMethod @WebResult(targetNamespace = "") @RequestWrapper(localName = "addEmployee", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.AddEmployee") @ResponseWrapper(localName = "addEmployeeResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.AddEmployeeResponse") @Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/addEmployeeRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/addEmployeeResponse", fault = { @FaultAction(className = EmployeeAlreadyExists_Exception.class, value = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/addEmployee/Fault/EmployeeAlreadyExists") }) public Employee addEmployee( @WebParam(name = "arg0", targetNamespace = "") int arg0, @WebParam(name = "arg1", targetNamespace = "") String arg1) throws EmployeeAlreadyExists_Exception ; /** * * @return * returns int */ @WebMethod @WebResult(targetNamespace = "") @RequestWrapper(localName = "countEmployees", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.CountEmployees") @ResponseWrapper(localName = "countEmployeesResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.CountEmployeesResponse") @Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/countEmployeesRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/countEmployeesResponse") public int countEmployees(); }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/AddEmployeeResponse.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/AddEmployeeResponse.java
package com.baeldung.jaxws.client; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for addEmployeeResponse complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="addEmployeeResponse"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="return" type="{http://bottomup.server.jaxws.baeldung.com/}employee" minOccurs="0"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "addEmployeeResponse", propOrder = { "_return" }) public class AddEmployeeResponse { @XmlElement(name = "return") protected Employee _return; /** * Gets the value of the return property. * * @return * possible object is * {@link Employee } * */ public Employee getReturn() { return _return; } /** * Sets the value of the return property. * * @param value * allowed object is * {@link Employee } * */ public void setReturn(Employee value) { this._return = value; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeService_Service.java
web-modules/jee-7/src/main/java/com/baeldung/jaxws/client/EmployeeService_Service.java
package com.baeldung.jaxws.client; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import javax.xml.namespace.QName; import javax.xml.ws.Service; import javax.xml.ws.WebEndpoint; import javax.xml.ws.WebServiceClient; import javax.xml.ws.WebServiceException; import javax.xml.ws.WebServiceFeature; /** * This class was generated by the JAX-WS RI. * JAX-WS RI 2.2.9-b130926.1035 * Generated source version: 2.2 * */ @WebServiceClient(name = "EmployeeService", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", wsdlLocation = "http://localhost:8080/employeeservice?wsdl") public class EmployeeService_Service extends Service { private final static URL EMPLOYEESERVICE_WSDL_LOCATION; private final static WebServiceException EMPLOYEESERVICE_EXCEPTION; private final static QName EMPLOYEESERVICE_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeService"); static { URL url = null; WebServiceException e = null; try { url = new URI("http://localhost:8080/employeeservice?wsdl").toURL(); } catch (MalformedURLException | URISyntaxException ex) { e = new WebServiceException(ex); } EMPLOYEESERVICE_WSDL_LOCATION = url; EMPLOYEESERVICE_EXCEPTION = e; } public EmployeeService_Service() { super(__getWsdlLocation(), EMPLOYEESERVICE_QNAME); } public EmployeeService_Service(WebServiceFeature... features) { super(__getWsdlLocation(), EMPLOYEESERVICE_QNAME, features); } public EmployeeService_Service(URL wsdlLocation) { super(wsdlLocation, EMPLOYEESERVICE_QNAME); } public EmployeeService_Service(URL wsdlLocation, WebServiceFeature... features) { super(wsdlLocation, EMPLOYEESERVICE_QNAME, features); } public EmployeeService_Service(URL wsdlLocation, QName serviceName) { super(wsdlLocation, serviceName); } public EmployeeService_Service(URL wsdlLocation, QName serviceName, WebServiceFeature... features) { super(wsdlLocation, serviceName, features); } /** * * @return * returns EmployeeService */ @WebEndpoint(name = "EmployeeServiceImplPort") public EmployeeService getEmployeeServiceImplPort() { return super.getPort(new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeServiceImplPort"), EmployeeService.class); } /** * * @param features * A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values. * @return * returns EmployeeService */ @WebEndpoint(name = "EmployeeServiceImplPort") public EmployeeService getEmployeeServiceImplPort(WebServiceFeature... features) { return super.getPort(new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeServiceImplPort"), EmployeeService.class, features); } private static URL __getWsdlLocation() { if (EMPLOYEESERVICE_EXCEPTION!= null) { throw EMPLOYEESERVICE_EXCEPTION; } return EMPLOYEESERVICE_WSDL_LOCATION; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/javaeeannotations/BankAppServletContextListener.java
web-modules/jee-7/src/main/java/com/baeldung/javaeeannotations/BankAppServletContextListener.java
package com.baeldung.javaeeannotations; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; @WebListener public class BankAppServletContextListener implements ServletContextListener { public void contextInitialized(ServletContextEvent sce) { sce.getServletContext().setAttribute("ATTR_DEFAULT_LANGUAGE", "english"); } public void contextDestroyed(ServletContextEvent sce) { System.out.println("CONTEXT DESTROYED"); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/javaeeannotations/AccountServlet.java
web-modules/jee-7/src/main/java/com/baeldung/javaeeannotations/AccountServlet.java
package com.baeldung.javaeeannotations; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.annotation.WebInitParam; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet( name = "BankAccountServlet", description = "Represents a Bank Account and it's transactions", urlPatterns = {"/account", "/bankAccount" }, initParams = { @WebInitParam(name = "type", value = "savings") } ) /*@ServletSecurity( value = @HttpConstraint(rolesAllowed = {"Member"}), httpMethodConstraints = {@HttpMethodConstraint(value = "POST", rolesAllowed = {"Admin"})} )*/ public class AccountServlet extends javax.servlet.http.HttpServlet { String accountType = null; public void init(ServletConfig config) throws ServletException { accountType = config.getInitParameter("type"); } public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { PrintWriter writer = response.getWriter(); writer.println("<html>Hello, I am an AccountServlet!</html>"); writer.flush(); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { double accountBalance = 1000d; String paramDepositAmt = request.getParameter("dep"); double depositAmt = Double.parseDouble(paramDepositAmt); accountBalance = accountBalance + depositAmt; PrintWriter writer = response.getWriter(); writer.println("<html> Balance of " + accountType + " account is: " + accountBalance + "</html>"); writer.flush(); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/javaeeannotations/UploadCustomerDocumentsServlet.java
web-modules/jee-7/src/main/java/com/baeldung/javaeeannotations/UploadCustomerDocumentsServlet.java
package com.baeldung.javaeeannotations; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.Part; @WebServlet(urlPatterns = { "/uploadCustDocs" }) @MultipartConfig( fileSizeThreshold = 1024 * 1024 * 20, maxFileSize = 1024 * 1024 * 20, maxRequestSize = 1024 * 1024 * 25, location = "D:/custDocs" ) public class UploadCustomerDocumentsServlet extends HttpServlet { protected void doPost( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { for (Part part : request.getParts()) { part.write("myFile"); } PrintWriter writer = response.getWriter(); writer.println("<html>File uploaded successfully!</html>"); writer.flush(); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jee-7/src/main/java/com/baeldung/javaeeannotations/LogInFilter.java
web-modules/jee-7/src/main/java/com/baeldung/javaeeannotations/LogInFilter.java
package com.baeldung.javaeeannotations; import java.io.IOException; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.annotation.WebFilter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /*@WebFilter( urlPatterns = "/bankAccount/*", filterName = "LogInFilter", description = "Filter all account transaction URLs" )*/ public class LogInFilter implements javax.servlet.Filter { public void init(FilterConfig filterConfig) throws ServletException { } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse res = (HttpServletResponse) response; res.sendRedirect(req.getContextPath() + "/login.jsp"); chain.doFilter(request, response); } public void destroy() { } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/vraptor/src/main/java/com/baeldung/daos/UserDao.java
web-modules/vraptor/src/main/java/com/baeldung/daos/UserDao.java
package com.baeldung.daos; import com.baeldung.models.User; import org.hibernate.Criteria; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.criterion.Restrictions; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; @RequestScoped public class UserDao { SessionFactory sessionFactory; public UserDao() { this(null); } @Inject public UserDao(SessionFactory sessionFactory) { this.sessionFactory = sessionFactory; } public Object add(User user) { Session session = sessionFactory.openSession(); session.beginTransaction(); Object Id = session.save(user); session.getTransaction().commit(); return Id; } public User findByEmail(String email) { Session session = sessionFactory.openSession(); session.beginTransaction(); Criteria criteria = session.createCriteria(User.class); criteria.add(Restrictions.eq("email", email)); criteria.setMaxResults(1); User u = (User) criteria.uniqueResult(); session.getTransaction().commit(); session.close(); return u; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/vraptor/src/main/java/com/baeldung/daos/PostDao.java
web-modules/vraptor/src/main/java/com/baeldung/daos/PostDao.java
package com.baeldung.daos; import com.baeldung.controllers.PostController; import com.baeldung.models.Post; import org.hibernate.Session; import org.hibernate.SessionFactory; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import java.util.List; import java.util.logging.Logger; @RequestScoped public class PostDao { private Logger logger = Logger.getLogger(PostController.class.getName()); private SessionFactory sessionFactory; public PostDao() {} @Inject public PostDao(SessionFactory sessionFactory) { this.sessionFactory = sessionFactory; } public Object add(Post post) { Session session = sessionFactory.openSession(); session.beginTransaction(); Object id = session.save(post); session.getTransaction().commit(); session.close(); return id; } public Post findById(int id) { Session session = sessionFactory.openSession(); session.beginTransaction(); Post post = (Post) session.get(Post.class, id); session.getTransaction().commit(); session.close(); return post; } public List<Post> all() { Session session = sessionFactory.openSession(); session.beginTransaction(); List<Post> posts = (List<Post>) session.createQuery("FROM Post p").list(); session.getTransaction().commit(); session.close(); return posts; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/vraptor/src/main/java/com/baeldung/controllers/AuthController.java
web-modules/vraptor/src/main/java/com/baeldung/controllers/AuthController.java
package com.baeldung.controllers; import br.com.caelum.vraptor.*; import br.com.caelum.vraptor.freemarker.FreemarkerView; import br.com.caelum.vraptor.validator.Validator; import com.baeldung.config.UserInfo; import com.baeldung.daos.UserDao; import com.baeldung.models.User; import org.mindrot.jbcrypt.BCrypt; import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; import java.util.Objects; import java.util.logging.Logger; @Controller public class AuthController { private Validator validator; private UserDao userDao; private Result result; private UserInfo userInfo; private Logger logger = Logger.getLogger(getClass().getName()); public AuthController() { this(null, null, null, null); } @Inject public AuthController(Validator validator, UserDao userDao, Result result, UserInfo userInfo) { this.validator = validator; this.userDao = userDao; this.result = result; this.userInfo = userInfo; } @Get("/register") public void registrationForm() { result.use(FreemarkerView.class).withTemplate("auth/register"); } @Post("/register") public void register(User user, HttpServletRequest request) { validator.validate(user); if(validator.hasErrors()) { result.include("errors", validator.getErrors()); } validator.onErrorRedirectTo(this).registrationForm(); if(!user.getPassword() .equals(request.getParameter("password_confirmation"))) { result.include("error", "Passwords Do Not Match"); result.redirectTo(this).registrationForm(); } user.setPassword( BCrypt.hashpw(user.getPassword(), BCrypt.gensalt())); Object resp = userDao.add(user); if(resp != null) { result.include("status", "Registration Successful! Now Login"); result.redirectTo(this).loginForm(); } else { result.include("error", "There was an error during registration"); result.redirectTo(this).registrationForm(); } } @Get("/login") public void loginForm() { result.use(FreemarkerView.class).withTemplate("auth/login"); } @Post("/login") public void login(HttpServletRequest request) { String password = request.getParameter("user.password"); String email = request.getParameter("user.email"); if(email.isEmpty() || password.isEmpty()) { result.include("error", "Email/Password is Required!"); result.redirectTo(AuthController.class).loginForm(); } User user = userDao.findByEmail(email); if(user != null && BCrypt.checkpw(password, user.getPassword())) { userInfo.setUser(user); result.include("status", "Login Successful!"); result.redirectTo(IndexController.class).index(); } else { result.include("error", "Email/Password Does Not Match!"); result.redirectTo(AuthController.class).loginForm(); } } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/vraptor/src/main/java/com/baeldung/controllers/IndexController.java
web-modules/vraptor/src/main/java/com/baeldung/controllers/IndexController.java
package com.baeldung.controllers; import br.com.caelum.vraptor.Controller; import br.com.caelum.vraptor.Path; import br.com.caelum.vraptor.Result; import br.com.caelum.vraptor.freemarker.FreemarkerView; import com.baeldung.daos.PostDao; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.inject.Inject; @Controller public class IndexController { private PostDao postDao; private final Result result; private static final Logger logger = LoggerFactory.getLogger(IndexController.class); public IndexController() { this(null, null); } @Inject public IndexController(Result result, PostDao postDao) { this.result = result; this.postDao = postDao; } @Path("/") public void index() { result.include("posts", postDao.all()); result.use(FreemarkerView.class).withTemplate("index"); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/vraptor/src/main/java/com/baeldung/controllers/PostController.java
web-modules/vraptor/src/main/java/com/baeldung/controllers/PostController.java
package com.baeldung.controllers; import br.com.caelum.vraptor.Controller; import br.com.caelum.vraptor.Get; import br.com.caelum.vraptor.Path; import br.com.caelum.vraptor.Result; import br.com.caelum.vraptor.freemarker.FreemarkerView; import br.com.caelum.vraptor.validator.Validator; import com.baeldung.config.UserInfo; import com.baeldung.daos.PostDao; import com.baeldung.models.Post; import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; import java.util.Objects; import java.util.logging.Logger; @Controller public class PostController { private Result result; private Logger logger = Logger.getLogger(PostController.class.getName()); private PostDao postDao; private UserInfo userInfo; private Validator validator; public PostController() {} @Inject public PostController(Result result, PostDao postDao, UserInfo userInfo, Validator validator) { this.result = result; this.postDao = postDao; this.userInfo = userInfo; this.validator = validator; } @Get("/post/add") public void addForm() { if(Objects.isNull(userInfo.getUser())) { result.include("error", "Please Login to Proceed"); result.redirectTo(AuthController.class).loginForm(); return; } result.use(FreemarkerView.class).withTemplate("posts/add"); } @br.com.caelum.vraptor.Post("/post/add") public void add(Post post) { post.setAuthor(userInfo.getUser()); validator.validate(post); if(validator.hasErrors()) result.include("errors", validator.getErrors()); validator.onErrorRedirectTo(this).addForm(); Object id = postDao.add(post); if(Objects.nonNull(id)) { result.include("status", "Post Added Successfully"); result.redirectTo(IndexController.class).index(); } else { result.include( "error", "There was an error creating the post. Try Again"); result.redirectTo(this).addForm(); } } @Get("/posts/{id}") public void view(int id) { result.include("post", postDao.findById(id)); result.use(FreemarkerView.class).withTemplate("view"); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/vraptor/src/main/java/com/baeldung/models/Post.java
web-modules/vraptor/src/main/java/com/baeldung/models/Post.java
package com.baeldung.models; import javax.persistence.*; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import java.time.LocalDateTime; import java.util.Date; import java.util.logging.Logger; @Entity @Table(name = "posts") public class Post { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; @NotNull @Size(min = 10) @Column(columnDefinition = "longtext") private String post; @NotNull @Size(min = 5, max = 100) @Column(unique = true) private String title; @NotNull @ManyToOne(targetEntity = User.class, optional = false) private User author; @Column(name = "created_at") private Date createdAt; @Column(name = "updated_at") private Date updatedAt; @Transient private Logger logger = Logger.getLogger(getClass().getName()); public Post() { createdAt = new Date(); updatedAt = new Date(); } public Post(String title, String post, User author) { this.title = title; this.post = post; this.author = author; createdAt = new Date(); updatedAt = new Date(); } public int getId() { return id; } public String getPost() { return post; } public void setPost(String post) { this.post = post; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public User getAuthor() { return author; } public void setAuthor(User author) { this.author = author; } public Date getCreatedAt() { return createdAt; } public void setCreatedAt(Date createdAt) { this.createdAt = createdAt; } public Date getUpdatedAt() { return updatedAt; } public void setUpdatedAt(Date updatedAt) { this.updatedAt = updatedAt; } @Override public String toString() { return "title: " + this.title + "\npost: " + this.post + "\nauthor: " + this.author +"\ncreatetdAt: " + this.createdAt + "\nupdatedAt: " + this.updatedAt; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/vraptor/src/main/java/com/baeldung/models/User.java
web-modules/vraptor/src/main/java/com/baeldung/models/User.java
package com.baeldung.models; import org.hibernate.validator.constraints.Email; import javax.persistence.*; import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; import java.time.LocalDateTime; import java.util.Date; @Entity @Table(name = "users") public class User { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; @NotNull @Size(min=3, max=255) private String name; @Column(unique = true) @NotNull @Email private String email; @NotNull @Size(min=6, max=255) private String password; @Column(name = "created_at") private Date createdAt; @Column(name = "updated_at") private Date updatedAt; public User() { updatedAt = new Date(); createdAt = new Date(); } public User(String name, String email, String password) { this.name = name; this.email = email; this.password = password; createdAt = new Date(); updatedAt = new Date(); } public int getId() { return id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public Date getCreatedAt() { return createdAt; } public void setCreatedAt(Date createdAt) { this.createdAt = createdAt; } public Date getUpdatedAt() { return updatedAt; } public void setUpdatedAt(Date updatedAt) { this.updatedAt = updatedAt; } @Override public String toString() { return "Name: " + this.name + "\nEmail: " + this.email; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/vraptor/src/main/java/com/baeldung/config/UserInfo.java
web-modules/vraptor/src/main/java/com/baeldung/config/UserInfo.java
package com.baeldung.config; import com.baeldung.models.User; import javax.enterprise.context.SessionScoped; import java.io.Serializable; @SessionScoped public class UserInfo implements Serializable { private User user; public UserInfo() {} public User getUser() { return user; } public void setUser(User user) { this.user = user; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/restx/src/test/java/restx/demo/rest/HelloResourceSpecIntegrationTest.java
web-modules/restx/src/test/java/restx/demo/rest/HelloResourceSpecIntegrationTest.java
package restx.demo.rest; import org.junit.runner.RunWith; import restx.tests.FindSpecsIn; import restx.tests.RestxSpecTestsRunner; @RunWith(RestxSpecTestsRunner.class) @FindSpecsIn("specs/hello") public class HelloResourceSpecIntegrationTest { /** * Useless, thanks to both @RunWith(RestxSpecTestsRunner.class) & @FindSpecsIn() * * @Rule * public RestxSpecRule rule = new RestxSpecRule(); * * @Test * public void test_spec() throws Exception { * rule.runTest(specTestPath); * } */ }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/restx/src/main/java/restx/demo/AppModule.java
web-modules/restx/src/main/java/restx/demo/AppModule.java
package restx.demo; import restx.config.ConfigLoader; import restx.config.ConfigSupplier; import restx.factory.Provides; import restx.security.*; import restx.factory.Module; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Charsets; import com.google.common.collect.ImmutableSet; import javax.inject.Named; import java.nio.file.Paths; @Module public class AppModule { @Provides public SignatureKey signatureKey() { return new SignatureKey("restx-demo -447494532235718370 restx-demo 801c9eaf-4116-48f2-906b-e979fba72757".getBytes(Charsets.UTF_8)); } @Provides @Named("restx.admin.password") public String restxAdminPassword() { return "4780"; } @Provides public ConfigSupplier appConfigSupplier(ConfigLoader configLoader) { // Load settings.properties in restx.demo package as a set of config entries return configLoader.fromResource("web-modules/restx/demo/settings"); } @Provides public CredentialsStrategy credentialsStrategy() { return new BCryptCredentialsStrategy(); } @Provides public BasicPrincipalAuthenticator basicPrincipalAuthenticator( SecuritySettings securitySettings, CredentialsStrategy credentialsStrategy, @Named("restx.admin.passwordHash") String defaultAdminPasswordHash, ObjectMapper mapper) { return new StdBasicPrincipalAuthenticator(new StdUserService<>( // use file based users repository. // Developer's note: prefer another storage mechanism for your users if you need real user management // and better perf new FileBasedUserRepository<>( StdUser.class, // this is the class for the User objects, that you can get in your app code // with RestxSession.current().getPrincipal().get() // it can be a custom user class, it just need to be json deserializable mapper, // this is the default restx admin, useful to access the restx admin console. // if one user with restx-admin role is defined in the repository, this default user won't be // available anymore new StdUser("admin", ImmutableSet.<String>of("*")), // the path where users are stored Paths.get("data/users.json"), // the path where credentials are stored. isolating both is a good practice in terms of security // it is strongly recommended to follow this approach even if you use your own repository Paths.get("data/credentials.json"), // tells that we want to reload the files dynamically if they are touched. // this has a performance impact, if you know your users / credentials never change without a // restart you can disable this to get better perfs true), credentialsStrategy, defaultAdminPasswordHash), securitySettings); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/restx/src/main/java/restx/demo/AppServer.java
web-modules/restx/src/main/java/restx/demo/AppServer.java
package restx.demo; import com.google.common.base.Optional; import restx.server.WebServer; import restx.server.Jetty11WebServer; /** * This class can be used to run the app. * * Alternatively, you can deploy the app as a war in a regular container like tomcat or jetty. * * Reading the port from system env PORT makes it compatible with heroku. */ public class AppServer { public static final String WEB_INF_LOCATION = "src/main/webapp/WEB-INF/web.xml"; public static final String WEB_APP_LOCATION = "src/main/webapp"; public static void main(String[] args) throws Exception { int port = Integer.valueOf(Optional.fromNullable(System.getenv("PORT")).or("8080")); WebServer server = new Jetty11WebServer(WEB_INF_LOCATION, WEB_APP_LOCATION, port, "0.0.0.0"); /* * load mode from system property if defined, or default to dev * be careful with that setting, if you use this class to launch your server in production, make sure to launch * it with -Drestx.mode=prod or change the default here */ System.setProperty("restx.mode", System.getProperty("restx.mode", "dev")); System.setProperty("restx.app.package", "restx.demo"); server.startAndAwait(); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/restx/src/main/java/restx/demo/Roles.java
web-modules/restx/src/main/java/restx/demo/Roles.java
package restx.demo; /** * A list of roles for the application. * * We don't use an enum here because it must be used inside an annotation. */ public final class Roles { public static final String HELLO_ROLE = "hello"; }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/restx/src/main/java/restx/demo/domain/Message.java
web-modules/restx/src/main/java/restx/demo/domain/Message.java
package restx.demo.domain; public class Message { private String message; public String getMessage() { return message; } public Message setMessage(final String message) { this.message = message; return this; } @Override public String toString() { return "Message{" + "message='" + message + '\'' + '}'; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/restx/src/main/java/restx/demo/rest/HelloResource.java
web-modules/restx/src/main/java/restx/demo/rest/HelloResource.java
package restx.demo.rest; import restx.demo.domain.Message; import restx.demo.Roles; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import restx.annotations.GET; import restx.annotations.POST; import restx.annotations.RestxResource; import restx.factory.Component; import restx.security.PermitAll; import restx.security.RolesAllowed; import restx.security.RestxSession; import javax.validation.constraints.NotNull; @Component @RestxResource public class HelloResource { /** * Say hello to currently logged in user. * * Authorized only for principals with Roles.HELLO_ROLE role. * * @return a Message to say hello */ @GET("/message") @RolesAllowed(Roles.HELLO_ROLE) public Message sayHello() { return new Message().setMessage(String.format( "hello %s, it's %s", RestxSession.current().getPrincipal().get().getName(), DateTime.now(DateTimeZone.UTC).toString("HH:mm:ss"))); } /** * Say hello to anybody. * * Does not require authentication. * * @return a Message to say hello */ @GET("/hello") @PermitAll public Message helloPublic(String who) { return new Message().setMessage(String.format( "hello %s, it's %s", who, DateTime.now(DateTimeZone.UTC).toString("HH:mm:ss"))); } public static class MyPOJO { @NotNull String value; public String getValue(){ return value; } public void setValue(String value){ this.value = value; } } @POST("/mypojo") @PermitAll public MyPOJO helloPojo(MyPOJO pojo){ pojo.setValue("hello "+pojo.getValue()); return pojo; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/wicket/src/main/test/java/com/baeldung/wicket/examples/HomePageIntegrationTest.java
web-modules/wicket/src/main/test/java/com/baeldung/wicket/examples/HomePageIntegrationTest.java
package com.baeldung.wicket.examples; import org.apache.wicket.util.tester.WicketTester; import org.junit.Before; import org.junit.Test; public class HomePageIntegrationTest { private WicketTester tester; @Before public void setUp() { tester = new WicketTester(new HelloWorldApplication()); } @Test public void whenPageInvoked_thanRenderedOK() { //start and render the test page tester.startPage(HelloWorld.class); //assert rendered page class tester.assertRenderedPage(HelloWorld.class); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/wicket/src/main/java/com/baeldung/wicket/examples/HelloWorldApplication.java
web-modules/wicket/src/main/java/com/baeldung/wicket/examples/HelloWorldApplication.java
package com.baeldung.wicket.examples; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.protocol.http.WebApplication; import com.baeldung.wicket.examples.cafeaddress.CafeAddress; public class HelloWorldApplication extends WebApplication { /** * @see org.apache.wicket.Application#getHomePage() */ @Override public Class<? extends WebPage> getHomePage() { return HelloWorld.class; } /** * @see org.apache.wicket.Application#init() */ @Override public void init() { super.init(); mountPage("/examples/helloworld", HelloWorld.class); mountPage("/examples/cafes", CafeAddress.class); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/wicket/src/main/java/com/baeldung/wicket/examples/HelloWorld.java
web-modules/wicket/src/main/java/com/baeldung/wicket/examples/HelloWorld.java
package com.baeldung.wicket.examples; import org.apache.wicket.markup.html.WebPage; public class HelloWorld extends WebPage { private static final long serialVersionUID = 1L; }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java
web-modules/wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java
package com.baeldung.wicket.examples.helloworld; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.basic.Label; public class HelloWorld extends WebPage { public HelloWorld() { add(new Label("hello", "Hello World!")); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java
web-modules/wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java
package com.baeldung.wicket.examples.cafeaddress; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.form.DropDownChoice; import org.apache.wicket.model.PropertyModel; import org.apache.wicket.request.mapper.parameter.PageParameters; import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; public class CafeAddress extends WebPage { private String selectedCafe; private Address address; private Map<String, Address> cafeNamesAndAddresses = new HashMap<>(); public CafeAddress(final PageParameters parameters) { super(parameters); initCafes(); ArrayList<String> cafeNames = new ArrayList<>(cafeNamesAndAddresses.keySet()); selectedCafe = cafeNames.get(0); address = new Address(cafeNamesAndAddresses.get(selectedCafe).getAddress()); final Label addressLabel = new Label("address", new PropertyModel<String>(this.address, "address")); addressLabel.setOutputMarkupId(true); final DropDownChoice<String> cafeDropdown = new DropDownChoice<>("cafes", new PropertyModel<>(this, "selectedCafe"), cafeNames); cafeDropdown.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { String name = (String) cafeDropdown.getDefaultModel().getObject(); address.setAddress(cafeNamesAndAddresses.get(name).getAddress()); target.add(addressLabel); } }); add(addressLabel); add(cafeDropdown); } private void initCafes() { this.cafeNamesAndAddresses.put("Linda's Cafe", new Address("35 Bower St.")); this.cafeNamesAndAddresses.put("Old Tree", new Address("2 Edgware Rd.")); } class Address implements Serializable { private String sAddress = ""; public Address(String address) { this.sAddress = address; } String getAddress() { return this.sAddress; } void setAddress(String address) { this.sAddress = address; } } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/blade/src/test/java/com/baeldung/blade/sample/AttributesExampleControllerLiveTest.java
web-modules/blade/src/test/java/com/baeldung/blade/sample/AttributesExampleControllerLiveTest.java
package com.baeldung.blade.sample; import static org.assertj.core.api.Assertions.assertThat; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; import org.junit.Test; public class AttributesExampleControllerLiveTest { @Test public void givenRequestAttribute_whenSet_thenRetrieveWithGet() throws Exception { final HttpUriRequest request = new HttpGet("http://localhost:9000/request-attribute-example"); try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() .build() .execute(request);) { assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo(AttributesExampleController.REQUEST_VALUE); } } @Test public void givenSessionAttribute_whenSet_thenRetrieveWithGet() throws Exception { final HttpUriRequest request = new HttpGet("http://localhost:9000/session-attribute-example"); try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() .build() .execute(request);) { assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo(AttributesExampleController.SESSION_VALUE); } } @Test public void givenHeader_whenSet_thenRetrieveWithGet() throws Exception { final HttpUriRequest request = new HttpGet("http://localhost:9000/header-example"); request.addHeader("a-header","foobar"); try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() .build() .execute(request);) { assertThat(httpResponse.getHeaders("a-header")[0].getValue()).isEqualTo("foobar"); } } @Test public void givenNoHeader_whenSet_thenRetrieveDefaultValueWithGet() throws Exception { final HttpUriRequest request = new HttpGet("http://localhost:9000/header-example"); try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() .build() .execute(request);) { assertThat(httpResponse.getHeaders("a-header")[0].getValue()).isEqualTo(AttributesExampleController.HEADER); } } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/blade/src/test/java/com/baeldung/blade/sample/AppLiveTest.java
web-modules/blade/src/test/java/com/baeldung/blade/sample/AppLiveTest.java
package com.baeldung.blade.sample; import static org.assertj.core.api.Assertions.assertThat; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPut; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; import org.junit.Test; public class AppLiveTest { @Test public void givenBasicRoute_whenGet_thenCorrectOutput() throws Exception { final HttpUriRequest request = new HttpGet("http://localhost:9000/basic-route-example"); try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() .build() .execute(request);) { assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("GET called"); } } @Test public void givenBasicRoute_whenPost_thenCorrectOutput() throws Exception { final HttpUriRequest request = new HttpPost("http://localhost:9000/basic-route-example"); try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() .build() .execute(request);) { assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("POST called"); } } @Test public void givenBasicRoute_whenPut_thenCorrectOutput() throws Exception { final HttpUriRequest request = new HttpPut("http://localhost:9000/basic-route-example"); try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() .build() .execute(request);) { assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("PUT called"); } } @Test public void givenBasicRoute_whenDelete_thenCorrectOutput() throws Exception { final HttpUriRequest request = new HttpDelete("http://localhost:9000/basic-route-example"); try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() .build() .execute(request);) { assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("DELETE called"); } } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/blade/src/test/java/com/baeldung/blade/sample/ParameterInjectionExampleControllerLiveTest.java
web-modules/blade/src/test/java/com/baeldung/blade/sample/ParameterInjectionExampleControllerLiveTest.java
package com.baeldung.blade.sample; import static org.assertj.core.api.Assertions.assertThat; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.client.utils.URIBuilder; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; import org.junit.Test; public class ParameterInjectionExampleControllerLiveTest { @Test public void givenFormParam_whenSet_thenRetrieveWithGet() throws Exception { URIBuilder builder = new URIBuilder("http://localhost:9000/params/form"); builder.setParameter("name", "Andrea Ligios"); final HttpUriRequest request = new HttpGet(builder.build()); try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() .build() .execute(request);) { assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("Andrea Ligios"); } } @Test public void givenPathParam_whenSet_thenRetrieveWithGet() throws Exception { final HttpUriRequest request = new HttpGet("http://localhost:9000/params/path/1337"); try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() .build() .execute(request);) { assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("1337"); } } // @Test // public void givenFileParam_whenSet_thenRetrieveWithGet() throws Exception { // // byte[] data = "this is some temp file content".getBytes("UTF-8"); // java.nio.file.Path tempFile = Files.createTempFile("baeldung_test_tempfiles", ".tmp"); // Files.write(tempFile, data, StandardOpenOption.WRITE); // // //HttpEntity entity = MultipartEntityBuilder.create().addPart("file", new FileBody(tempFile.toFile())).build(); // HttpEntity entity = MultipartEntityBuilder.create().addTextBody("field1", "value1") // .addBinaryBody("fileItem", tempFile.toFile(), ContentType.create("application/octet-stream"), "file1.txt").build(); // // final HttpPost post = new HttpPost("http://localhost:9000/params-file"); // post.setEntity(entity); // // try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create().build().execute(post);) { // assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("file1.txt"); // } // } @Test public void givenHeader_whenSet_thenRetrieveWithGet() throws Exception { final HttpUriRequest request = new HttpGet("http://localhost:9000/params/header"); request.addHeader("customheader", "foobar"); try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() .build() .execute(request);) { assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("foobar"); } } @Test public void givenNoCookie_whenCalled_thenReadDefaultValue() throws Exception { final HttpUriRequest request = new HttpGet("http://localhost:9000/params/cookie"); try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() .build() .execute(request);) { assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("default value"); } } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/blade/src/test/java/com/baeldung/blade/sample/RouteExampleControllerLiveTest.java
web-modules/blade/src/test/java/com/baeldung/blade/sample/RouteExampleControllerLiveTest.java
package com.baeldung.blade.sample; import static org.assertj.core.api.Assertions.assertThat; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPut; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; import org.junit.Test; public class RouteExampleControllerLiveTest { @Test public void givenRoute_whenGet_thenCorrectOutput() throws Exception { final HttpUriRequest request = new HttpGet("http://localhost:9000/route-example"); try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() .build() .execute(request);) { assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("GET called"); } } @Test public void givenRoute_whenPost_thenCorrectOutput() throws Exception { final HttpUriRequest request = new HttpPost("http://localhost:9000/route-example"); try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() .build() .execute(request);) { assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("POST called"); } } @Test public void givenRoute_whenPut_thenCorrectOutput() throws Exception { final HttpUriRequest request = new HttpPut("http://localhost:9000/route-example"); try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() .build() .execute(request);) { assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("PUT called"); } } @Test public void givenRoute_whenDelete_thenCorrectOutput() throws Exception { final HttpUriRequest request = new HttpDelete("http://localhost:9000/route-example"); try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() .build() .execute(request);) { assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("DELETE called"); } } @Test public void givenAnotherRoute_whenGet_thenCorrectOutput() throws Exception { final HttpUriRequest request = new HttpGet("http://localhost:9000/another-route-example"); try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() .build() .execute(request);) { assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("GET called"); } } @Test public void givenAllMatchRoute_whenGet_thenCorrectOutput() throws Exception { final HttpUriRequest request = new HttpGet("http://localhost:9000/allmatch-route-example"); try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() .build() .execute(request);) { assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("ALLMATCH called"); } } @Test public void givenAllMatchRoute_whenPost_thenCorrectOutput() throws Exception { final HttpUriRequest request = new HttpPost("http://localhost:9000/allmatch-route-example"); try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() .build() .execute(request);) { assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("ALLMATCH called"); } } @Test public void givenAllMatchRoute_whenPut_thenCorrectOutput() throws Exception { final HttpUriRequest request = new HttpPut("http://localhost:9000/allmatch-route-example"); try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() .build() .execute(request);) { assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("ALLMATCH called"); } } @Test public void givenAllMatchRoute_whenDelete_thenCorrectOutput() throws Exception { final HttpUriRequest request = new HttpDelete("http://localhost:9000/allmatch-route-example"); try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() .build() .execute(request);) { assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("ALLMATCH called"); } } @Test public void givenRequestAttribute_whenRenderedWithTemplate_thenCorrectlyEvaluateIt() throws Exception { final HttpUriRequest request = new HttpGet("http://localhost:9000/template-output-test"); try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() .build() .execute(request);) { assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("<h1>Hello, Blade!</h1>"); } } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/blade/src/main/java/com/baeldung/blade/sample/ParameterInjectionExampleController.java
web-modules/blade/src/main/java/com/baeldung/blade/sample/ParameterInjectionExampleController.java
package com.baeldung.blade.sample; import java.nio.file.Files; import java.nio.file.StandardOpenOption; import com.baeldung.blade.sample.vo.User; import com.blade.mvc.annotation.CookieParam; import com.blade.mvc.annotation.GetRoute; import com.blade.mvc.annotation.HeaderParam; import com.blade.mvc.annotation.JSON; import com.blade.mvc.annotation.MultipartParam; import com.blade.mvc.annotation.Param; import com.blade.mvc.annotation.Path; import com.blade.mvc.annotation.PathParam; import com.blade.mvc.annotation.PostRoute; import com.blade.mvc.http.Response; import com.blade.mvc.multipart.FileItem; import com.blade.mvc.ui.RestResponse; @Path public class ParameterInjectionExampleController { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(ParameterInjectionExampleController.class); @GetRoute("/params/form") public void formParam(@Param String name, Response response) { log.info("name: " + name); response.text(name); } @GetRoute("/params/path/:uid") public void restfulParam(@PathParam Integer uid, Response response) { log.info("uid: " + uid); response.text(String.valueOf(uid)); } @PostRoute("/params-file") // DO NOT USE A SLASH WITHIN THE ROUTE OR IT WILL BREAK (?) @JSON public RestResponse<?> fileParam(@MultipartParam FileItem fileItem) throws Exception { try { byte[] fileContent = fileItem.getData(); log.debug("Saving the uploaded file"); java.nio.file.Path tempFile = Files.createTempFile("baeldung_tempfiles", ".tmp"); Files.write(tempFile, fileContent, StandardOpenOption.WRITE); return RestResponse.ok(); } catch (Exception e) { log.error(e.getMessage(), e); return RestResponse.fail(e.getMessage()); } } @GetRoute("/params/header") public void headerParam(@HeaderParam String customheader, Response response) { log.info("Custom header: " + customheader); response.text(customheader); } @GetRoute("/params/cookie") public void cookieParam(@CookieParam(defaultValue = "default value") String myCookie, Response response) { log.info("myCookie: " + myCookie); response.text(myCookie); } @PostRoute("/params/vo") public void voParam(@Param User user, Response response) { log.info("user as voParam: " + user.toString()); response.html(user.toString() + "<br/><br/><a href='/'>Back</a>"); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/blade/src/main/java/com/baeldung/blade/sample/LogExampleController.java
web-modules/blade/src/main/java/com/baeldung/blade/sample/LogExampleController.java
package com.baeldung.blade.sample; import com.blade.mvc.annotation.Path; import com.blade.mvc.annotation.Route; import com.blade.mvc.http.Response; @Path public class LogExampleController { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LogExampleController.class); @Route(value = "/test-logs") public void testLogs(Response response) { log.trace("This is a TRACE Message"); log.debug("This is a DEBUG Message"); log.info("This is an INFO Message"); log.warn("This is a WARN Message"); log.error("This is an ERROR Message"); response.text("Check in ./logs"); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/blade/src/main/java/com/baeldung/blade/sample/App.java
web-modules/blade/src/main/java/com/baeldung/blade/sample/App.java
package com.baeldung.blade.sample; import com.baeldung.blade.sample.interceptors.BaeldungMiddleware; import com.blade.Blade; import com.blade.event.EventType; import com.blade.mvc.WebContext; import com.blade.mvc.http.Session; public class App { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(App.class); public static void main(String[] args) { Blade.of() .get("/", ctx -> ctx.render("index.html")) .get("/basic-route-example", ctx -> ctx.text("GET called")) .post("/basic-route-example", ctx -> ctx.text("POST called")) .put("/basic-route-example", ctx -> ctx.text("PUT called")) .delete("/basic-route-example", ctx -> ctx.text("DELETE called")) .addStatics("/custom-static") // .showFileList(true) .enableCors(true) .before("/user/*", ctx -> log.info("[NarrowedHook] Before '/user/*', URL called: " + ctx.uri())) .on(EventType.SERVER_STARTED, e -> { String version = WebContext.blade() .env("app.version") .orElse("N/D"); log.info("[Event::serverStarted] Loading 'app.version' from configuration, value: " + version); }) .on(EventType.SESSION_CREATED, e -> { Session session = (Session) e.attribute("session"); session.attribute("mySessionValue", "Baeldung"); }) .use(new BaeldungMiddleware()) .start(App.class, args); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/blade/src/main/java/com/baeldung/blade/sample/AttributesExampleController.java
web-modules/blade/src/main/java/com/baeldung/blade/sample/AttributesExampleController.java
package com.baeldung.blade.sample; import com.blade.mvc.annotation.GetRoute; import com.blade.mvc.annotation.Path; import com.blade.mvc.http.Request; import com.blade.mvc.http.Response; import com.blade.mvc.http.Session; @Path public class AttributesExampleController { public final static String REQUEST_VALUE = "Some Request value"; public final static String SESSION_VALUE = "1337"; public final static String HEADER = "Some Header"; @GetRoute("/request-attribute-example") public void getRequestAttribute(Request request, Response response) { request.attribute("request-val", REQUEST_VALUE); String requestVal = request.attribute("request-val"); response.text(requestVal); } @GetRoute("/session-attribute-example") public void getSessionAttribute(Request request, Response response) { Session session = request.session(); session.attribute("session-val", SESSION_VALUE); String sessionVal = session.attribute("session-val"); response.text(sessionVal); } @GetRoute("/header-example") public void getHeader(Request request, Response response) { String headerVal = request.header("a-header", HEADER); response.header("a-header", headerVal); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/blade/src/main/java/com/baeldung/blade/sample/RouteExampleController.java
web-modules/blade/src/main/java/com/baeldung/blade/sample/RouteExampleController.java
package com.baeldung.blade.sample; import com.baeldung.blade.sample.configuration.BaeldungException; import com.blade.mvc.WebContext; import com.blade.mvc.annotation.DeleteRoute; import com.blade.mvc.annotation.GetRoute; import com.blade.mvc.annotation.Path; import com.blade.mvc.annotation.PostRoute; import com.blade.mvc.annotation.PutRoute; import com.blade.mvc.annotation.Route; import com.blade.mvc.http.HttpMethod; import com.blade.mvc.http.Request; import com.blade.mvc.http.Response; @Path public class RouteExampleController { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(RouteExampleController.class); @GetRoute("/route-example") public String get() { return "get.html"; } @PostRoute("/route-example") public String post() { return "post.html"; } @PutRoute("/route-example") public String put() { return "put.html"; } @DeleteRoute("/route-example") public String delete() { return "delete.html"; } @Route(value = "/another-route-example", method = HttpMethod.GET) public String anotherGet() { return "get.html"; } @Route(value = "/allmatch-route-example") public String allmatch() { return "allmatch.html"; } @Route(value = "/triggerInternalServerError") public void triggerInternalServerError() { int x = 1 / 0; } @Route(value = "/triggerBaeldungException") public void triggerBaeldungException() throws BaeldungException { throw new BaeldungException("Foobar Exception to threat differently"); } @Route(value = "/user/foo") public void urlCoveredByNarrowedWebhook(Response response) { response.text("Check out for the WebHook covering '/user/*' in the logs"); } @GetRoute("/load-configuration-in-a-route") public void loadConfigurationInARoute(Response response) { String authors = WebContext.blade() .env("app.authors", "Unknown authors"); log.info("[/load-configuration-in-a-route] Loading 'app.authors' from configuration, value: " + authors); response.render("index.html"); } @GetRoute("/template-output-test") public void templateOutputTest(Request request, Response response) { request.attribute("name", "Blade"); response.render("template-output-test.html"); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/blade/src/main/java/com/baeldung/blade/sample/configuration/LoadConfig.java
web-modules/blade/src/main/java/com/baeldung/blade/sample/configuration/LoadConfig.java
package com.baeldung.blade.sample.configuration; import com.blade.Blade; import com.blade.ioc.annotation.Bean; import com.blade.loader.BladeLoader; import com.blade.mvc.WebContext; @Bean public class LoadConfig implements BladeLoader { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoadConfig.class); @Override public void load(Blade blade) { String version = WebContext.blade() .env("app.version") .orElse("N/D"); String authors = WebContext.blade() .env("app.authors", "Unknown authors"); log.info("[LoadConfig] loaded 'app.version' (" + version + ") and 'app.authors' (" + authors + ") in a configuration bean"); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/blade/src/main/java/com/baeldung/blade/sample/configuration/ScheduleExample.java
web-modules/blade/src/main/java/com/baeldung/blade/sample/configuration/ScheduleExample.java
package com.baeldung.blade.sample.configuration; import com.blade.ioc.annotation.Bean; import com.blade.task.annotation.Schedule; @Bean public class ScheduleExample { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(ScheduleExample.class); @Schedule(name = "baeldungTask", cron = "0 */1 * * * ?") public void runScheduledTask() { log.info("[ScheduleExample] This is a scheduled Task running once per minute."); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/blade/src/main/java/com/baeldung/blade/sample/configuration/GlobalExceptionHandler.java
web-modules/blade/src/main/java/com/baeldung/blade/sample/configuration/GlobalExceptionHandler.java
package com.baeldung.blade.sample.configuration; import com.blade.ioc.annotation.Bean; import com.blade.mvc.WebContext; import com.blade.mvc.handler.DefaultExceptionHandler; @Bean public class GlobalExceptionHandler extends DefaultExceptionHandler { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(GlobalExceptionHandler.class); @Override public void handle(Exception e) { if (e instanceof BaeldungException) { Exception baeldungException = (BaeldungException) e; String msg = baeldungException.getMessage(); log.error("[GlobalExceptionHandler] Intercepted an exception to threat with additional logic. Error message: " + msg); WebContext.response() .render("index.html"); } else { super.handle(e); } } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/blade/src/main/java/com/baeldung/blade/sample/configuration/BaeldungException.java
web-modules/blade/src/main/java/com/baeldung/blade/sample/configuration/BaeldungException.java
package com.baeldung.blade.sample.configuration; public class BaeldungException extends RuntimeException { public BaeldungException(String message) { super(message); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/blade/src/main/java/com/baeldung/blade/sample/vo/User.java
web-modules/blade/src/main/java/com/baeldung/blade/sample/vo/User.java
package com.baeldung.blade.sample.vo; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import lombok.Getter; import lombok.Setter; public class User { @Getter @Setter private String name; @Getter @Setter private String site; @Override public String toString() { return ReflectionToStringBuilder.toString(this); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/blade/src/main/java/com/baeldung/blade/sample/interceptors/BaeldungMiddleware.java
web-modules/blade/src/main/java/com/baeldung/blade/sample/interceptors/BaeldungMiddleware.java
package com.baeldung.blade.sample.interceptors; import com.blade.mvc.RouteContext; import com.blade.mvc.hook.WebHook; public class BaeldungMiddleware implements WebHook { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(BaeldungMiddleware.class); @Override public boolean before(RouteContext context) { log.info("[BaeldungMiddleware] called before Route method and other WebHooks"); return true; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/blade/src/main/java/com/baeldung/blade/sample/interceptors/BaeldungHook.java
web-modules/blade/src/main/java/com/baeldung/blade/sample/interceptors/BaeldungHook.java
package com.baeldung.blade.sample.interceptors; import com.blade.ioc.annotation.Bean; import com.blade.mvc.RouteContext; import com.blade.mvc.hook.WebHook; @Bean public class BaeldungHook implements WebHook { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(BaeldungHook.class); @Override public boolean before(RouteContext ctx) { log.info("[BaeldungHook] called before Route method"); return true; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jakarta-servlets-3/src/main/java/com/baeldung/jakartaeetomcat/CurrentDateAndTime.java
web-modules/jakarta-servlets-3/src/main/java/com/baeldung/jakartaeetomcat/CurrentDateAndTime.java
package com.baeldung.jakartaeetomcat; import java.io.IOException; import java.io.PrintWriter; import java.time.LocalDateTime; import jakarta.servlet.ServletException; import jakarta.servlet.annotation.WebServlet; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @WebServlet(name = "CurrentDateAndTime", urlPatterns = { "/date-time" }) public class CurrentDateAndTime extends HttpServlet { LocalDateTime currentDate = LocalDateTime.now(); protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); currentDate = LocalDateTime.now(); try (PrintWriter out = response.getWriter()) { out.printf(""" <html> <head> <title> Current Date And Time </title> </head> <body> <h2> Servlet current date and time at %s </h2> <br/> Date and Time %s </body> </html> """, request.getContextPath(), currentDate); } } @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/hilla/src/main/java/com/example/demo/DemoData.java
web-modules/hilla/src/main/java/com/example/demo/DemoData.java
package com.example.demo; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.springframework.stereotype.Component; @Component public class DemoData implements ApplicationRunner { private final ContactRepository contactRepository; public DemoData(ContactRepository contactRepository) { this.contactRepository = contactRepository; } @Override public void run(ApplicationArguments args) { String[] firstNames = { "John", "Jane", "Alice", "Bob", "Carol", "David", "Eve", "Frank", "Grace", "Hank", "Ivy", "Jack", "Kate", "Luke", "Mary", "Ned", "Olga", "Paul", "Rose", "Sam" }; String[] lastNames = { "Smith", "Johnson", "Williams", "Jones", "Brown", "Davis", "Miller", "Wilson", "Moore", "Taylor", "Anderson", "Thomas", "Jackson", "White", "Harris", "Martin", "Thompson", "Garcia", "Martinez", "Robinson" }; for (int i = 0; i < 50; i++) { String name = firstNames[(int) (Math.random() * firstNames.length)] + " " + lastNames[(int) (Math.random() * lastNames.length)]; String email = name.replaceAll(" ", ".") .toLowerCase() + "@example.com"; String phone = "+1-555-" + (int) (Math.random() * 1000) + "-" + (int) (Math.random() * 10000); contactRepository.save(new Contact(name, email, phone)); } } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/hilla/src/main/java/com/example/demo/package-info.java
web-modules/hilla/src/main/java/com/example/demo/package-info.java
@NonNullApi package com.example.demo; import org.springframework.lang.NonNullApi;
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/hilla/src/main/java/com/example/demo/ContactRepository.java
web-modules/hilla/src/main/java/com/example/demo/ContactRepository.java
package com.example.demo; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; public interface ContactRepository extends JpaRepository<Contact, Long>, JpaSpecificationExecutor<Contact> { }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/hilla/src/main/java/com/example/demo/DemoApplication.java
web-modules/hilla/src/main/java/com/example/demo/DemoApplication.java
package com.example.demo; import com.vaadin.flow.component.page.AppShellConfigurator; import com.vaadin.flow.theme.Theme; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication @Theme("hilla") public class DemoApplication implements AppShellConfigurator { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/hilla/src/main/java/com/example/demo/ContactService.java
web-modules/hilla/src/main/java/com/example/demo/ContactService.java
package com.example.demo; import com.vaadin.flow.server.auth.AnonymousAllowed; import com.vaadin.hilla.BrowserCallable; import com.vaadin.hilla.crud.CrudRepositoryService; import java.util.List; @BrowserCallable @AnonymousAllowed public class ContactService extends CrudRepositoryService<Contact, Long, ContactRepository> { public List<Contact> findAll() { return getRepository().findAll(); } public Contact findById(Long id) { return getRepository().findById(id) .orElseThrow(); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/hilla/src/main/java/com/example/demo/Contact.java
web-modules/hilla/src/main/java/com/example/demo/Contact.java
package com.example.demo; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.Id; import jakarta.validation.constraints.Email; import jakarta.validation.constraints.Size; @Entity public class Contact { @Id @GeneratedValue private Long id; @Size(min = 2) private String name; @Email private String email; private String phone; public Contact() { } public Contact(String name, String email, String phone) { this.name = name; this.email = email; this.phone = phone; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public @Size(min = 2) String getName() { return name; } public void setName(@Size(min = 2) String name) { this.name = name; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/struts-2/src/test/java/com/baeldung/struts/test/CarActionTest.java
web-modules/struts-2/src/test/java/com/baeldung/struts/test/CarActionTest.java
//package com.baeldung.struts.test; // //import org.apache.struts2.StrutsTestCase; //import org.junit.Test; // //import com.baeldung.struts.CarAction; //import com.opensymphony.xwork2.ActionProxy; // //public class CarActionTest extends StrutsTestCase { // // public void testgivenCarOptions_WhenferrariSelected_ThenShowMessage() throws Exception { // request.setParameter("carName", "ferrari"); // ActionProxy proxy = getActionProxy("/tutorial/car.action"); // CarAction carAction = (CarAction) proxy.getAction(); // String result = proxy.execute(); // assertEquals(result, "success"); // assertEquals(carAction.getCarMessage(), "Ferrari Fan!"); // } // // public void testgivenCarOptions_WhenbmwSelected_ThenShowMessage() throws Exception { // request.setParameter("carName", "bmw"); // ActionProxy proxy = getActionProxy("/tutorial/car.action"); // CarAction carAction = (CarAction) proxy.getAction(); // String result = proxy.execute(); // assertEquals(result, "success"); // assertEquals(carAction.getCarMessage(), "BMW Fan!"); // } // //}
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/struts-2/src/main/java/com/baeldung/struts/CarAction.java
web-modules/struts-2/src/main/java/com/baeldung/struts/CarAction.java
package com.baeldung.struts; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.Result; @Namespace("/tutorial") @Action("/car") @Result(name = "success", location = "/result.jsp") public class CarAction { private String carName; private String carMessage; private CarMessageService carMessageService = new CarMessageService(); public String execute() { System.out.println("inside execute(): carName is" + carName); this.setCarMessage(this.carMessageService.getMessage(carName)); return "success"; } public String getCarName() { return carName; } public void setCarName(String carName) { this.carName = carName; } public String getCarMessage() { return carMessage; } public void setCarMessage(String carMessage) { this.carMessage = carMessage; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/struts-2/src/main/java/com/baeldung/struts/CarMessageService.java
web-modules/struts-2/src/main/java/com/baeldung/struts/CarMessageService.java
package com.baeldung.struts; public class CarMessageService { public String getMessage(String carName) { System.out.println("inside getMessage()" + carName); if (carName.equalsIgnoreCase("ferrari")){ return "Ferrari Fan!"; } else if (carName.equalsIgnoreCase("bmw")){ return "BMW Fan!"; } else{ return "please choose ferrari Or bmw"; } } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jakarta-ee/src/test/java/com/baeldung/eclipse/krazo/AppUnitTest.java
web-modules/jakarta-ee/src/test/java/com/baeldung/eclipse/krazo/AppUnitTest.java
package com.baeldung.eclipse.krazo; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; /** * Dummy Test */ public class AppUnitTest { @Test public void test() { assertTrue(true); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jakarta-ee/src/test/java/com/baeldung/eclipse/krazo/UserControllerUnitTest.java
web-modules/jakarta-ee/src/test/java/com/baeldung/eclipse/krazo/UserControllerUnitTest.java
package com.baeldung.eclipse.krazo; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; import org.eclipse.krazo.core.ModelsImpl; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import jakarta.mvc.Models; import jakarta.mvc.binding.BindingResult; /** * The class contains unit tests. We do only unit tests. Most of the classes are mocked */ @DisplayName("Eclipse Krazo MVC 2.0 Test Suite") class UserControllerUnitTest { @InjectMocks UserController userController = new UserController(); @Mock Models models; @Mock BindingResult bindingResult; @BeforeEach public void setUpClass() { MockitoAnnotations.initMocks(this); } @Test @DisplayName("Test Show Form") void whenShowForm_thenReturnViewName() { assertNotNull(userController.showForm()); assertEquals("user.jsp", userController.showForm()); } @Test @DisplayName("Test Save User Success") void whenSaveUser_thenReturnSuccess() { when(bindingResult.isFailed()).thenReturn(false); User user = new User(); assertNotNull(userController.saveUser(user)); assertDoesNotThrow(() -> userController.saveUser(user)); assertEquals("redirect:users/success", userController.saveUser(user)); } @Test @DisplayName("Test Save User Binding Errors") void whenSaveUser_thenReturnError() { when(bindingResult.isFailed()).thenReturn(true); Models testModels = new ModelsImpl(); when(models.put(anyString(), any())).thenReturn(testModels); User user = getUser(); assertNotNull(userController.saveUser(user)); assertDoesNotThrow(() -> userController.saveUser(user)); assertEquals("user.jsp", userController.saveUser(user)); } @Test @DisplayName("Test Save User Success View") void whenSaveUserSuccess_thenRedirectSuccess() { assertNotNull(userController.saveUserSuccess()); assertDoesNotThrow(() -> userController.saveUserSuccess()); assertEquals("success.jsp", userController.saveUserSuccess()); } @Test @DisplayName("Test Get Users API") void whenGetUser_thenReturnUsers() { when(bindingResult.isFailed()).thenReturn(false); User user= getUser(); assertNotNull(user); assertEquals(30, user.getAge()); assertEquals("john doe", user.getName()); assertEquals("anymail", user.getEmail()); assertEquals("99887766554433", user.getPhone()); assertEquals("1", user.getId()); userController.saveUser(user); userController.saveUser(user); userController.saveUser(user); assertNotNull(userController.getUsers()); assertDoesNotThrow(() -> userController.getUsers()); assertEquals(3, userController.getUsers().size()); } private User getUser() { User user = new User(); user.setId("1"); user.setName("john doe"); user.setAge(30); user.setEmail("anymail"); user.setPhone("99887766554433"); return user; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jakarta-ee/src/test/java/com/baeldung/stringtosoapmessage/StringToSOAPMsgUnitTest.java
web-modules/jakarta-ee/src/test/java/com/baeldung/stringtosoapmessage/StringToSOAPMsgUnitTest.java
package com.baeldung.stringtosoapmessage; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; import jakarta.xml.soap.SOAPBody; import jakarta.xml.soap.SOAPMessage; public class StringToSOAPMsgUnitTest { private final String sampleSoapXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" + "<soapenv:Header/>" + "<soapenv:Body>" + "<m:GetStockPrice xmlns:m=\"http://example.com/stock\">" + "<m:StockName>GOOG</m:StockName>" + "</m:GetStockPrice>" + "</soapenv:Body>" + "</soapenv:Envelope>"; @Test public void givenSOAPString_whenUsingSAAJMessageFactory_thenReturnSOAPMessage() throws Exception { SOAPMessage message = StringToSOAPMsg.usingSAAJMessageFactory(sampleSoapXml); SOAPBody body = message.getSOAPBody(); assertNotNull(message, "SOAPMessage should not be null"); assertNotNull(body, "SOAP Body should not be null"); assertTrue(body.getTextContent().contains("GOOG"), "Expected 'GOOG' not found in the SOAP body"); } @Test public void givenSOAPString_whenUsingDOMParsing_thenReturnSOAPMessage() throws Exception { SOAPMessage message = StringToSOAPMsg.usingDOMParsing(sampleSoapXml); SOAPBody body = message.getSOAPBody(); assertNotNull(message, "SOAPMessage should not be null"); assertNotNull(body, "SOAP Body should not be null"); assertTrue(body.getTextContent().contains("GOOG"), "Expected 'GOOG' not found in the SOAP body"); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jakarta-ee/src/test/java/com/baeldung/soapmessage/SoapMessageUnitTest.java
web-modules/jakarta-ee/src/test/java/com/baeldung/soapmessage/SoapMessageUnitTest.java
package com.baeldung.soapmessage; import jakarta.xml.soap.MessageFactory; import jakarta.xml.soap.MimeHeaders; import jakarta.xml.soap.SOAPBody; import jakarta.xml.soap.SOAPEnvelope; import jakarta.xml.soap.SOAPException; import jakarta.xml.soap.SOAPHeader; import jakarta.xml.soap.SOAPMessage; import jakarta.xml.soap.SOAPPart; import org.junit.jupiter.api.Test; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import javax.xml.namespace.NamespaceContext; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathFactory; import java.io.IOException; import java.io.InputStream; import java.util.Iterator; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; class SoapMessageUnitTest { @Test void givenXml_whenGetHeader_thenReturnHeader() throws Exception { SOAPEnvelope soapEnvelope = getSoapEnvelope(); SOAPHeader soapHeader = soapEnvelope.getHeader(); assertNotNull(soapHeader); } @Test void givenXml_whenGetBody_thenReturnBody() throws Exception { SOAPEnvelope soapEnvelope = getSoapEnvelope(); SOAPBody soapBody = soapEnvelope.getBody(); assertNotNull(soapBody); } @Test void whenGetElementsByTagName_thenReturnCorrectBodyElement() throws Exception { SOAPEnvelope soapEnvelope = getSoapEnvelope(); SOAPBody soapBody = soapEnvelope.getBody(); NodeList nodes = soapBody.getElementsByTagName("be:Name"); assertNotNull(nodes); Node node = nodes.item(0); assertEquals("Working with JUnit", node.getTextContent()); } @Test void whenGetElementsByTagName_thenReturnCorrectHeaderElement() throws Exception { SOAPEnvelope soapEnvelope = getSoapEnvelope(); SOAPHeader soapHeader = soapEnvelope.getHeader(); NodeList nodes = soapHeader.getElementsByTagName("be:Username"); assertNotNull(nodes); Node node = nodes.item(0); assertNotNull(node); assertEquals("baeldung", node.getTextContent()); } @Test void whenGetElementUsingIterator_thenReturnCorrectBodyElement() throws Exception { SOAPEnvelope soapEnvelope = getSoapEnvelope(); SOAPBody soapBody = soapEnvelope.getBody(); NodeList childNodes = soapBody.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); if ("Name".equals(node.getLocalName())) { String name = node.getTextContent(); assertEquals("Working with JUnit", name); } } } @Test void whenGetElementUsingXPath_thenReturnCorrectResult() throws Exception { SOAPEnvelope soapEnvelope = getSoapEnvelope(); SOAPBody soapBody = soapEnvelope.getBody(); XPathFactory xPathFactory = XPathFactory.newInstance(); XPath xpath = xPathFactory.newXPath(); xpath.setNamespaceContext(new NamespaceContext() { @Override public String getNamespaceURI(String prefix) { if ("be".equals(prefix)) { return "http://www.baeldung.com/soap/"; } return null; } @Override public String getPrefix(String namespaceURI) { return null; } @Override public Iterator<String> getPrefixes(String namespaceURI) { return null; } }); XPathExpression expression = xpath.compile("//be:Name/text()"); String name = (String) expression.evaluate(soapBody, XPathConstants.STRING); assertEquals("Working with JUnit", name); } @Test void whenGetElementUsingXPathAndIgnoreNamespace_thenReturnCorrectResult() throws Exception { SOAPEnvelope soapEnvelope = getSoapEnvelope(); SOAPBody soapBody = soapEnvelope.getBody(); XPathFactory xPathFactory = XPathFactory.newInstance(); XPath xpath = xPathFactory.newXPath(); XPathExpression expression = xpath.compile("//*[local-name()='Name']/text()"); String name = (String) expression.evaluate(soapBody, XPathConstants.STRING); assertEquals("Working with JUnit", name); } private SOAPEnvelope getSoapEnvelope() throws IOException, SOAPException { InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("soap-message.xml"); SOAPMessage soapMessage = MessageFactory.newInstance().createMessage(new MimeHeaders(), inputStream); SOAPPart part = soapMessage.getSOAPPart(); return part.getEnvelope(); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jakarta-ee/src/main/java/com/baeldung/eclipse/krazo/UserApplication.java
web-modules/jakarta-ee/src/main/java/com/baeldung/eclipse/krazo/UserApplication.java
package com.baeldung.eclipse.krazo; import jakarta.ws.rs.ApplicationPath; import jakarta.ws.rs.core.Application; /** * Default JAX-RS application listening on /app */ @ApplicationPath("/app") public class UserApplication extends Application { }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jakarta-ee/src/main/java/com/baeldung/eclipse/krazo/User.java
web-modules/jakarta-ee/src/main/java/com/baeldung/eclipse/krazo/User.java
package com.baeldung.eclipse.krazo; import jakarta.enterprise.context.RequestScoped; import jakarta.inject.Named; import jakarta.mvc.RedirectScoped; import jakarta.mvc.binding.MvcBinding; import jakarta.validation.constraints.Email; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Null; import jakarta.validation.constraints.Size; import jakarta.ws.rs.FormParam; import java.io.Serializable; @Named("user") @RedirectScoped public class User implements Serializable { @MvcBinding @Null private String id; @MvcBinding @NotNull @Size(min = 1, message = "Name cannot be blank") @FormParam("name") private String name; @MvcBinding @Min(value = 18, message = "The minimum age of the user should be 18 years") @FormParam("age") private int age; @MvcBinding @Email(message = "The email cannot be blank and should be in a valid format") @Size(min=3, message = "Email cannot be empty") @FormParam("email") private String email; @MvcBinding @Null @FormParam("phone") private String phone; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jakarta-ee/src/main/java/com/baeldung/eclipse/krazo/UserController.java
web-modules/jakarta-ee/src/main/java/com/baeldung/eclipse/krazo/UserController.java
package com.baeldung.eclipse.krazo; import jakarta.inject.Inject; import jakarta.mvc.Controller; import jakarta.mvc.Models; import jakarta.mvc.binding.BindingResult; import jakarta.mvc.security.CsrfProtected; import jakarta.validation.Valid; import jakarta.ws.rs.BeanParam; import jakarta.ws.rs.GET; import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.MediaType; import java.util.ArrayList; import java.util.List; import java.util.UUID; /** * The class contains two controllers and a REST API */ @Path("users") public class UserController { @Inject private BindingResult bindingResult; private static final List<User> users = new ArrayList<>(); @Inject private Models models; /** * This is a controller. It displays a initial form to the user. * @return The view name */ @GET @Controller public String showForm() { return "user.jsp"; } /** * The method handles the form submits * Handles HTTP POST and is CSRF protected. The client invoking this controller should provide a CSRF token. * @param user The user details that has to be stored * @return Returns a view name */ @POST @Controller @CsrfProtected public String saveUser(@Valid @BeanParam User user) { if (bindingResult.isFailed()) { models.put("errors", bindingResult.getAllErrors()); return "user.jsp"; } String id = UUID.randomUUID().toString(); user.setId(id); users.add(user); return "redirect:users/success"; } /** * Handles a redirect view * @return The view name */ @GET @Controller @Path("success") public String saveUserSuccess() { return "success.jsp"; } /** * The REST API that returns all the user details in the JSON format * @return The list of users that are saved. The List<User> is converted into Json Array. * If no user is present a empty array is returned */ @GET @Produces(MediaType.APPLICATION_JSON) public List<User> getUsers() { return users; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/jakarta-ee/src/main/java/com/baeldung/stringtosoapmessage/StringToSOAPMsg.java
web-modules/jakarta-ee/src/main/java/com/baeldung/stringtosoapmessage/StringToSOAPMsg.java
package com.baeldung.stringtosoapmessage; import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.dom.DOMSource; import org.w3c.dom.Document; import jakarta.xml.soap.MessageFactory; import jakarta.xml.soap.SOAPMessage; import jakarta.xml.soap.SOAPPart; public class StringToSOAPMsg { public static SOAPMessage usingSAAJMessageFactory(String soapXml) throws Exception { ByteArrayInputStream input = new ByteArrayInputStream(soapXml.getBytes(StandardCharsets.UTF_8)); MessageFactory factory = MessageFactory.newInstance(); return factory.createMessage(null, input); } public static SOAPMessage usingDOMParsing(String soapXml) throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(new ByteArrayInputStream(soapXml.getBytes(StandardCharsets.UTF_8))); MessageFactory factory = MessageFactory.newInstance(); SOAPMessage message = factory.createMessage(); SOAPPart part = message.getSOAPPart(); part.setContent(new DOMSource(doc.getDocumentElement())); message.saveChanges(); return message; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/linkrest/src/main/java/com/baeldung/LinkRestApplication.java
web-modules/linkrest/src/main/java/com/baeldung/LinkRestApplication.java
package com.baeldung; import javax.ws.rs.ApplicationPath; import org.apache.cayenne.configuration.server.ServerRuntime; import org.glassfish.jersey.server.ResourceConfig; import com.nhl.link.rest.runtime.LinkRestBuilder; import com.nhl.link.rest.runtime.LinkRestRuntime; @ApplicationPath("/linkrest") public class LinkRestApplication extends ResourceConfig { public LinkRestApplication() { ServerRuntime cayenneRuntime = ServerRuntime.builder() .addConfig("cayenne-linkrest-project.xml") .build(); LinkRestRuntime lrRuntime = LinkRestBuilder.build(cayenneRuntime); super.register(lrRuntime); packages("com.baeldung.linkrest.apis"); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/linkrest/src/main/java/com/baeldung/cayenne/Employee.java
web-modules/linkrest/src/main/java/com/baeldung/cayenne/Employee.java
package com.baeldung.cayenne; import com.baeldung.cayenne.auto._Employee; public class Employee extends _Employee { private static final long serialVersionUID = 1L; }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/linkrest/src/main/java/com/baeldung/cayenne/Department.java
web-modules/linkrest/src/main/java/com/baeldung/cayenne/Department.java
package com.baeldung.cayenne; import com.baeldung.cayenne.auto._Department; public class Department extends _Department { private static final long serialVersionUID = 1L; }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/linkrest/src/main/java/com/baeldung/cayenne/auto/_Department.java
web-modules/linkrest/src/main/java/com/baeldung/cayenne/auto/_Department.java
package com.baeldung.cayenne.auto; import java.util.List; import org.apache.cayenne.CayenneDataObject; import org.apache.cayenne.exp.Property; import com.baeldung.cayenne.Employee; /** * Class _Department was generated by Cayenne. * It is probably a good idea to avoid changing this class manually, * since it may be overwritten next time code is regenerated. * If you need to make any customizations, please use subclass. */ public abstract class _Department extends CayenneDataObject { private static final long serialVersionUID = 1L; public static final String DEP_ID_PK_COLUMN = "dep_id"; public static final Property<String> NAME = Property.create("name", String.class); public static final Property<List<Employee>> EMPLOYEES = Property.create("employees", List.class); public void setName(String name) { writeProperty("name", name); } public String getName() { return (String)readProperty("name"); } public void addToEmployees(Employee obj) { addToManyTarget("employees", obj, true); } public void removeFromEmployees(Employee obj) { removeToManyTarget("employees", obj, true); } @SuppressWarnings("unchecked") public List<Employee> getEmployees() { return (List<Employee>)readProperty("employees"); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/linkrest/src/main/java/com/baeldung/cayenne/auto/_Employee.java
web-modules/linkrest/src/main/java/com/baeldung/cayenne/auto/_Employee.java
package com.baeldung.cayenne.auto; import org.apache.cayenne.CayenneDataObject; import org.apache.cayenne.exp.Property; import com.baeldung.cayenne.Department; /** * Class _Employee was generated by Cayenne. * It is probably a good idea to avoid changing this class manually, * since it may be overwritten next time code is regenerated. * If you need to make any customizations, please use subclass. */ public abstract class _Employee extends CayenneDataObject { private static final long serialVersionUID = 1L; public static final String EMP_ID_PK_COLUMN = "emp_id"; public static final Property<String> NAME = Property.create("name", String.class); public static final Property<Department> DEPARTMENT = Property.create("department", Department.class); public void setName(String name) { writeProperty("name", name); } public String getName() { return (String)readProperty("name"); } public void setDepartment(Department department) { setToOneTarget("department", department, true); } public Department getDepartment() { return (Department)readProperty("department"); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/linkrest/src/main/java/com/baeldung/linkrest/apis/DepartmentResource.java
web-modules/linkrest/src/main/java/com/baeldung/linkrest/apis/DepartmentResource.java
package com.baeldung.linkrest.apis; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Configuration; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; import com.baeldung.cayenne.Department; import com.nhl.link.rest.DataResponse; import com.nhl.link.rest.LinkRest; import com.nhl.link.rest.SimpleResponse; @Path("department") @Produces(MediaType.APPLICATION_JSON) public class DepartmentResource { @Context private Configuration config; @GET public DataResponse<Department> getAll(@Context UriInfo uriInfo) { return LinkRest.select(Department.class, config).uri(uriInfo).get(); } @GET @Path("{id}") public DataResponse<Department> getOne(@PathParam("id") int id, @Context UriInfo uriInfo) { return LinkRest.select(Department.class, config).byId(id).uri(uriInfo).getOne(); } @POST public SimpleResponse create(String data) { return LinkRest.create(Department.class, config).sync(data); } @PUT public SimpleResponse createOrUpdate(String data) { return LinkRest.createOrUpdate(Department.class, config).sync(data); } @Path("{id}/employees") public EmployeeSubResource getEmployees(@PathParam("id") int id, @Context UriInfo uriInfo) { return new EmployeeSubResource(id, config); } @DELETE @Path("{id}") public SimpleResponse delete(@PathParam("id") int id) { return LinkRest.delete(Department.class, config).id(id).delete(); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/linkrest/src/main/java/com/baeldung/linkrest/apis/EmployeeSubResource.java
web-modules/linkrest/src/main/java/com/baeldung/linkrest/apis/EmployeeSubResource.java
package com.baeldung.linkrest.apis; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Configuration; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; import com.baeldung.cayenne.Department; import com.baeldung.cayenne.Employee; import com.nhl.link.rest.DataResponse; import com.nhl.link.rest.LinkRest; import com.nhl.link.rest.SimpleResponse; @Produces(MediaType.APPLICATION_JSON) public class EmployeeSubResource { private Configuration config; private int departmentId; public EmployeeSubResource(int departmentId, Configuration config) { this.departmentId = departmentId; this.config = config; } public EmployeeSubResource() { } @GET public DataResponse<Employee> getAll(@Context UriInfo uriInfo) { return LinkRest.select(Employee.class, config).toManyParent(Department.class, departmentId, Department.EMPLOYEES).uri(uriInfo).get(); } @GET @Path("{id}") public DataResponse<Employee> getOne(@PathParam("id") int id, @Context UriInfo uriInfo) { return LinkRest.select(Employee.class, config).toManyParent(Department.class, departmentId, Department.EMPLOYEES).byId(id).uri(uriInfo).getOne(); } @POST public SimpleResponse create(String data) { return LinkRest.create(Employee.class, config).toManyParent(Department.class, departmentId, Department.EMPLOYEES).sync(data); } @PUT public SimpleResponse createOrUpdate(String data) { return LinkRest.create(Employee.class, config).toManyParent(Department.class, departmentId, Department.EMPLOYEES).sync(data); } @DELETE @Path("{id}") public SimpleResponse delete(@PathParam("id") int id) { return LinkRest.delete(Employee.class, config).toManyParent(Department.class, departmentId, Department.EMPLOYEES).id(id).delete(); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/bootique/src/test/java/com/baeldung/bootique/AppUnitTest.java
web-modules/bootique/src/test/java/com/baeldung/bootique/AppUnitTest.java
package com.baeldung.bootique; import com.baeldung.bootique.service.HelloService; import io.bootique.BQRuntime; import io.bootique.test.junit.BQDaemonTestFactory; import io.bootique.test.junit.BQTestFactory; import org.junit.Rule; import org.junit.Test; import static org.junit.Assert.assertEquals; public class AppUnitTest { @Rule public BQTestFactory bqTestFactory = new BQTestFactory(); @Rule public BQDaemonTestFactory bqDaemonTestFactory = new BQDaemonTestFactory(); @Test public void givenService_expectBoolen() { BQRuntime runtime = bqTestFactory.app("--server").autoLoadModules().createRuntime(); HelloService service = runtime.getInstance(HelloService.class); assertEquals(true, service.save()); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/bootique/src/main/java/com/baeldung/bootique/App.java
web-modules/bootique/src/main/java/com/baeldung/bootique/App.java
package com.baeldung.bootique; import com.baeldung.bootique.module.ModuleBinder; import com.baeldung.bootique.router.IndexController; import com.baeldung.bootique.router.SaveController; import com.google.inject.Module; import io.bootique.Bootique; import io.bootique.jersey.JerseyModule; import io.bootique.log.BootLogger; import java.util.function.Supplier; public class App { public static void main(String[] args) { Module module = binder -> JerseyModule.extend(binder).addResource(IndexController.class) .addResource(SaveController.class); Bootique.app(args).module(module).module(ModuleBinder.class).bootLogger(new BootLogger() { @Override public void trace(Supplier<String> arg0) { // ... } @Override public void stdout(String arg0) { // ... } @Override public void stderr(String arg0, Throwable arg1) { // ... } @Override public void stderr(String arg0) { // ... } }).autoLoadModules().exec(); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/bootique/src/main/java/com/baeldung/bootique/service/HelloService.java
web-modules/bootique/src/main/java/com/baeldung/bootique/service/HelloService.java
package com.baeldung.bootique.service; public interface HelloService { boolean save(); }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/bootique/src/main/java/com/baeldung/bootique/service/impl/HelloServiceImpl.java
web-modules/bootique/src/main/java/com/baeldung/bootique/service/impl/HelloServiceImpl.java
package com.baeldung.bootique.service.impl; import com.baeldung.bootique.service.HelloService; public class HelloServiceImpl implements HelloService { @Override public boolean save() { return true; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/bootique/src/main/java/com/baeldung/bootique/router/SaveController.java
web-modules/bootique/src/main/java/com/baeldung/bootique/router/SaveController.java
package com.baeldung.bootique.router; import com.baeldung.bootique.service.HelloService; import com.google.inject.Inject; import javax.ws.rs.POST; import javax.ws.rs.Path; @Path("/save") public class SaveController { @Inject HelloService helloService; @POST public String save() { return "Data Saved!"; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/bootique/src/main/java/com/baeldung/bootique/router/IndexController.java
web-modules/bootique/src/main/java/com/baeldung/bootique/router/IndexController.java
package com.baeldung.bootique.router; import javax.ws.rs.GET; import javax.ws.rs.Path; @Path("/") public class IndexController { @GET public String index() { return "Hello, baeldung!"; } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false
eugenp/tutorials
https://github.com/eugenp/tutorials/blob/4463e58ffb73fe599bac2479abd84598c6e70a1a/web-modules/bootique/src/main/java/com/baeldung/bootique/module/ModuleBinder.java
web-modules/bootique/src/main/java/com/baeldung/bootique/module/ModuleBinder.java
package com.baeldung.bootique.module; import com.baeldung.bootique.service.HelloService; import com.baeldung.bootique.service.impl.HelloServiceImpl; import com.google.inject.Binder; import com.google.inject.Module; public class ModuleBinder implements Module { @Override public void configure(Binder binder) { binder.bind(HelloService.class).to(HelloServiceImpl.class); } }
java
MIT
4463e58ffb73fe599bac2479abd84598c6e70a1a
2026-01-04T14:45:57.069771Z
false