1 / 21

Servlets, JSP e Web Services

Servlets, JSP e Web Services. Eider Oliveira 13 de junho de 2002. Interação Cliente Servidor na Internet. Código cliente: Applets JavaScript Alternativas da Microsoft Código servidor CGI, NSAPI, ISAPI PHP, Coldfusion, ASP, etc Servlets. Protocolo HTTP.

raven
Download Presentation

Servlets, JSP e Web Services

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Servlets, JSP eWeb Services Eider Oliveira 13 de junho de 2002

  2. Interação Cliente Servidorna Internet • Código cliente: • Applets • JavaScript • Alternativas da Microsoft • Código servidor • CGI, NSAPI, ISAPI • PHP, Coldfusion, ASP, etc • Servlets

  3. Protocolo HTTP • Protocolo sem estado (“stateless”) • Solicitações: • Get • Post • Resposta: • página HTML

  4. Solicitação GET GET /index.html HTTP/1.0 Connection: Keep-Alive User-Agent: Mozilla/4.08 [en] (X11; I; Linux 2.0.36 i586; Nav) Host: silverfish.sd.monash.edu.au:3213 Accept: image/gif, image/jpeg, image/png, */* Accept-Encoding: gzip Accept-Language: en Accept-Charset: iso-8859-1,*,utf-8

  5. Resposta HTTP/1.1 200 OK Date: Mon, 10 May 1999 06:15:49 GMT Server: Apache/1.3.0 (Unix) Connection: close Content-Type: text/html <HTML><HEAD> <meta http-equiv="refresh" content="0; URL=http://bcomp.csse.monash.edu.au/"> </HEAD>

  6. Formulário <HTML> <HEAD> <TITLE></TITLE> </HEAD> <BODY> <FORM METHOD=POST ACTION="servlet/Hello"> Qual seu nome? <INPUT TYPE=TEXT NAME="nome"><P> <INPUT TYPE=SUBMIT> </FORM> </BODY> </HTML>

  7. Envio de dados: POST POST /servlet/Hello HTTP/1.0 Referer: http://silverfish.sd.monash.edu.au:3213/ Connection: Keep-Alive User-Agent: Mozilla/4.08 [en] (X11; I; Linux 2.0.36 i586; Nav) Host: silverfish.sd.monash.edu.au:3213 Accept: image/gif, image/jpeg, image/pjpeg, image/png, */* Accept-Encoding: gzip Accept-Language: en Accept-Charset: iso-8859-1,*,utf-8 Content-type: application/x-www-form-urlencoded Content-length: 22 nome=Ex+President+Bush

  8. Servlets • Programas em Java • Executam exclusivamente no servidor • Atendem requisições GET e POST • Atuam conjuntamente com o Servidor Web

  9. Servlets Máquina Cliente Máquina Servidora Browser Servlet Server Solicitação e parâmetros Resposta (HTML) Servlet Servlet Servlet

  10. Características de uma Servlet • Baixo consumo de memória • Uma instância atende diversas requisições • Possibilita reutilização de recursos caros • Grande velocidade de execução

  11. import java.io.*; import java.text.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; publicclass EchoServlet extends HttpServlet { publicvoiddoGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html"); ServletOutputStream out = response.getOutputStream(); out.println("<HTML><BODY>“); out.println("the value of parameter theParameter is “); out.println(request.getParameter("theParameter")); out.println("</BODY></HTML>"); } } Uma Servlet Simples

  12. Problemas... • A interface HTML está difusa dentro do código Java • Qualquer alteração visual implica em recompilação da Servlet • Quem modifica os fontes: o Webmaster ou o programador?

  13. Solução: JSP • Java Server Pages • Código Java dentro das páginas HTML (Scriptlet) • Compilação transparente em Servlets • Uso de JavaBeans e Taglibs

  14. <HTML> <HEAD> <TITLE>JSP example</TITLE> </HEAD> <BODY> <% out.println(“Good afternoon “+ request.getParameter(“name”)); %> </BODY> </HTML> Exemplo de JSP

  15. “E que *&%@!! são Web Services?” • SOAP: uma outra forma de RPC? • Fundamentalmente: sim • XML: lento e complexo • Mas interoperável! • A mágica dos padrões da indústria… • Indo além do arquitetado e alcançando o dinâmico • RPC: foi uma boa idéia nos anos 70 e continua sendo uma boa idéia.

  16. Web Services... • “A” aplicação: Sinergia • Onde estão meus distribuidores, cobradores, vendedores. • Um sistema de saúde sem redigitação de formulários • Uma loja promove leilão do seu saldo de estoque

  17. Java Web Services Developer Pack • APIs de Web Services e Applicações: • Java API for XML Processing (JAXP) , RPC (JAX-RPC), Messaging (JAXM), Registries (JAXR) • UDDI-based registry server (Universal Description, Discovery and Integration) • The JSP Standard Tag Library • Desenvolvimento e testes: • A UDDI-based registry server • Apache Tomcat • Java Secure Socket Extension (JSSE) • Apache Ant build tool • Documentação

  18. Established Deployment Experiments Launch Curvas de Adoção J2EE Web Services Language JSP Applets 95 96 97 98 99 00 01 02

  19. Evolução da Computação Distribuída Web Services Web Apps 3/N-Tier Client-Server Next After that Network of Embedded Things Catch Phrase The Network Is the Computer Legacy tothe Web The Computer Is the Network Network of Things Objects System Collections Components Scale 100s 1000s 1000000s 10000000s 100000000s 1000000000s When/Peak 1984/1987 1990/1993 1996/1999 2001/2003 1998/2004 2004/2007 Leaf Protocol(s) X X +HTTP +RMI+JVM) +XML, + ? + ? Directory(s) NIS, NIS+ + CDS + LDAP (*) +UDDI + ? + ? Session RPC, XDR +CORBA +CORBA, RMI + SOAP, XML + ? + ? Schematic (A seqüência Gingell)

  20. Olhando a frente • `Web Services’ é a infraestrutura • E o mundo de Java inclui muito mais... • Desktops • Embedded • Real Time • Wireless • Smart Cards • Games ?!

More Related