how to create a Servlet in a c# client

JumboDumbo 11 Reputation points
2022-05-08T20:53:23.893+00:00

So I am trying to make a Servlet in my c# programm related to my h2 database and I cant figure out how to create a c# Servlet, or Client?

This is my Servlet(implemented in Java):

@WebServlet(name = "helloServlet", value = "/hello-servlet")
public class HelloServlet extends HttpServlet {

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    Employee employee = JSP_Client.getEmployee(request.getParameter("name"));
    System.out.println(employee);
    request.setAttribute("selectedEmployee", employee);
    RequestDispatcher requestDispatcher = request.getRequestDispatcher("employee.jsp");
    requestDispatcher.forward(request,response);
}
public void destroy() {
}

}

And my Client looks like this:

package Controller;

import common.IEmployee;
import common.ILogBookEntry;
import model.Employee;
import org.eclipse.microprofile.rest.client.RestClientBuilder;

import java.net.URI;
import java.util.ArrayList;

public class Client {
public static IEmployee employees;
public static ILogBookEntry entries;

public Client() {
}

public static void employeeClient() {
    employees = RestClientBuilder.newBuilder()
            .baseUri(URI.create("http://localhost:8080/LERN-1.0-SNAPSHOT/api"))
            .followRedirects(true)
            .build(IEmployee.class);
}
public static void logbookEntryClient() {
    entries = RestClientBuilder.newBuilder()
            .baseUri(URI.create("http://localhost:8080/LERN-1.0-SNAPSHOT/api"))
                    .followRedirects(true)
                    .build(ILogBookEntry.class);
}

public static ArrayList<Employee> getAllEmployees(){
    employeeClient();
    return (ArrayList<Employee>) employees.getAllEmployees();
}

public static Employee getEmployee(String name){
    for (Employee emp:getAllEmployees()) {
        if(emp.getFirstName().equals(name)){
            return emp;
        }
    }
    return null;
}

}

Can someone help me implement a c# client, as I am quite new to c# and dotNet

Developer technologies C#
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.