java web development
TRANSCRIPT
Java Web Development
Introducere
AGENDA Servlets JSP Scriptlets JSTL Expression Language (EL) Standard actions Custom Tags Exception Management Struts
Servlets
- Stramosi - CGI (Common Gateway Interface)
- Parte a Controller din Pattern-ul MVC ???
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
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.
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
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)
Servlets
Atelier – HelloWorld servlet
Servlets
Questions ????
JSP
- Lifecycle - Implicit objects
JSP
- O evolutie fireasca a Servlet-ilor- Orientat View- Programatorul View NU trebuie sa stie foarte multa Java
- ATENTIE !!!!! – extinde javax.servlet.http.HttpServlet
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