I
I
Igor2017-07-14 13:26:23
Java
Igor, 2017-07-14 13:26:23

Java Servlet Is the approach correct?

Hello, I'm learning Java EE and creating a client-server project in parallel. Where the client part is written in C #, and the server part in Java. For client interaction with the server, I use a servlet (interaction occurs through API commands in json format, not http request parameters).

Question: is the approach of using only one servlet that accepts the request, passes it to the appropriate modules for processing and then sends the response back?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Cheremisin, 2017-07-14
@ApolonIn

If it is so convenient for you, in the form of a proxy servlet, then yes, the approach is normal. Yes, work through json is also normal. Don't forget that there are also different methods GET/PUT/POST/DELETE/UPDATE/HEAD etc. Very often they are the most convenient to manipulate. For example, by GET we take data, by POST - we transfer, by PUT - we update, by DELETE - we delete :-)
Well, in a large project it is still more convenient to divide servlets by data types.

F
Fat Lorrie, 2017-07-14
@Free_ze

is the approach of using only one servlet that accepts the request, passes it to the appropriate modules for processing, and then sends the response back?

Yes. It works in a similar way, for example DispatcherServletfrom Spring MVC :
mvc.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question