开发者

Servlets and backend relationship

开发者 https://www.devze.com 2023-01-21 00:40 出处:网络
We can say Servlets are back end right? An interviewer once said \"Servlets are not back end and for example Spring, EJB do\". Is开发者_C百科 it right? Even spring MVC internally uses servlets to hand

We can say Servlets are back end right? An interviewer once said "Servlets are not back end and for example Spring, EJB do". Is开发者_C百科 it right? Even spring MVC internally uses servlets to handle the requests right?

Thank You.


"Servlets are not back end and for example Spring, EJB do"

the second part of that conjunction, "and for example,Spring, EJB do" doesn't make any sense.

Servlets run on the server, just like EJBs and Spring. They are at the 'top' of the back end. The typically invoke services that do things. From that point of view they are back end.

An example of client side code, i.e. something that is not back end, would be anything run in the browser, like javascript.


Yes and No. A servlet can be a back end to a http client request, but it may be a front end to an EJB, JDBC, or other remote call.


Some people treat backend as only your DAO and service layers and they generally treat servlets as part of your View in MVC. The current standard is to use Servlets only as a controller and there should not technically hold any business logic (in legacy applications there will be lot of business logic in servlets and jsp too). In that sense a servlet is truly not a backend but sometimes it can be treated as a backend too.


Servlets can be both front end and back end components depending on how you build your system.

For example JSPs are part of the view in a MVC design pattern but they are servlets. Even when you use JSF and serve hxtml pages they are processed and served internally by a servlet.

Of course, if you do an AJAX call from a html page to a servlet in which you open for example a JDBC connection, fetch some data and serve back the data to be processed by the java script then yes your servlet is part of the back end.

0

精彩评论

暂无评论...
验证码 换一张
取 消