简体   繁体   中英

Java EE Web Applications vs Web Services

Can someone confirm or clarify for me:

From what I can tell, Java EE web apps consist of a Servlet and/or JSP driven dynamic web page being fed back in the HTTP response, triggered by the Java EE server receiving a HTTP GET or POST request.

From what I can tell, Java EE web services also make use of Servlets as the web tier components, however a WS Servlet receives a SOAP message and validates the contents of those messages with whatever WSDL the Servlet is WARed with. The response is also packaged in SOAP and sent back to the requestor.

So, from what I can tell, both Java EE web apps and WSes use Servlets as the web components, with the only real difference being the protocol used (raw HTTP vs SOAP, which is an extension of HTTP).

This is the best I could come up with - am I right? Totally wrong? Close?

The biggest difference is not in how they are delivered, but in how they are used. Web applications are targeted to web browsers and usually serve full HTML-based applications . Web services, on the other hand, are purposed to serve raw data for another application to consume.

You are right, and servlets are just a means to connect the code at a given webapp context to a URI path. Whether the servlet is serving HTML or WS is inconsequential to the webapp container, it's just data with a MIME type being sent back.

You could also manage the same thing with a filter under Servlet 2.3 and later specifications. Spring does this, and has a very robust means of adding to the filter chain to support it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM