java web development

12
Java Web Development Introducere

Upload: daniel-georgescu

Post on 17-Jul-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Java Web Development

Java Web Development

Introducere

Page 2: Java Web Development

AGENDA Servlets JSP Scriptlets JSTL Expression Language (EL) Standard actions Custom Tags Exception Management Struts

Page 3: Java Web Development

Servlets

- Stramosi - CGI (Common Gateway Interface)

- Parte a Controller din Pattern-ul MVC ???

Page 4: Java Web Development

ServletsHTTP Methods - GET : The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI - POST : The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line - PUT : The PUT method requests that the enclosed entity be stored under the supplied Request-URI - DELETE : The DELETE method requests that the origin server delete the resource identified by the

Request-URI - TRACE : The TRACE method is used to invoke a remote, application-layer loop- back of the request message - HEAD : The HEAD method is identical to GET except that the server MUST NOT return a message body in the response

Page 5: Java Web Development

Servlets- OPTIONS : The OPTIONS method represents a request for information about the communication

options available on the request/response chain identified by the Request-URI. This method allows the client to determine the options and/or requirements associated with a resource, or the capabilities of a server, without implying a resource action or initiating a resource retrieval.

- CONNECT : This specification reserves the method name CONNECT for use with a proxy that can dynamically switch to being a tunnel 

Metode idempotente vs Metode non-idempotente

Idempotenta este proprietatea metodelor HTTP de a raspunde cu acelasi continut indiferent de numarul de request-uri efectuate. Cu alte cuvinte acestea sunt metode ce nu au efecte pe parte de server.

Page 6: Java Web Development

Servlets GET - idempotent or safe (no side effects on server)

as it requests to return the content on the server and not modify it

POST - not impotent or unsafe (side effects on server)as it might modify the contents on the server

HEAD - idempotent or safe (no side effects on server)as it will just ask for header part and not the content in the response (response similar to GET except the body)

PUT - not impotent or unsafe (side effects on server)ask the server to put or modify data on server at particular uri

DELETE - not impotent or unsafe (side effects on server)delete the resource on server

OPTIONS - idempotent or safe (no side effects on server)asks for options available on server like content-length

TRACE - idempotent or safe (no side effects on server)ask to return traceback of the request

CONNECT - idempotent or safe (no side effects on server)just ask to connect to the server with host and port args

Resurse online :http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol

Page 7: Java Web Development

ServletsMetode puse la dispozitie de clasa javax.servlet.http.HttpServlet

• doDelete(HttpServletRequest req, HttpServletResponse resp)• doGet(HttpServletRequest req, HttpServletResponse resp)• doHead(HttpServletRequest req, HttpServletResponse resp)• doOptions(HttpServletRequest req, HttpServletResponse

resp)• doPost(HttpServletRequest req, HttpServletResponse resp)• doPut(HttpServletRequest req, HttpServletResponse resp)• doTrace(HttpServletRequest req, HttpServletResponse resp)

Page 8: Java Web Development

Servlets

Atelier – HelloWorld servlet

Page 9: Java Web Development

Servlets

Questions ????

Page 10: Java Web Development

JSP

- Lifecycle - Implicit objects

Page 11: Java Web Development

JSP

- O evolutie fireasca a Servlet-ilor- Orientat View- Programatorul View NU trebuie sa stie foarte multa Java

- ATENTIE !!!!! – extinde javax.servlet.http.HttpServlet

Page 12: Java Web Development

JSPJSP – Lifecycle1) JSP page translation2) JSP page compilation3) Class loading4) Create the instance5) Call the jspInit() method6) Call the _jspService() method ATENTIE – In JSP metodele cu “_”ca prefix NU pot fi suprascrise

(overriden ???) metoda _jspService() NU POATE FI SUPRASCRISA

Am ramas la pagina 307