230 likes | 431 Views
Java. Omar Rana University of South Asia. Course Overview JAVA. C/C++ and JAVA Comparison OOP in JAVA Exception Handling Streams Graphics User Interface Event Handling Game Programming Graphics Database Connectivity Network Programming. J2EE. HTML / CSS JavaScript Servlets JSP
E N D
Java Omar Rana University of South Asia
Course OverviewJAVA • C/C++ and JAVA Comparison • OOP in JAVA • Exception Handling • Streams • Graphics User Interface • Event Handling • Game Programming • Graphics • Database Connectivity • Network Programming
J2EE • HTML / CSS • JavaScript • Servlets • JSP • JSF • JAVA Beans • JSP using XML Tags • MVC Architecture • Programming in Layers • XML technologies
Web Application • Java Categories • J2me • J2sdk • J2EE
Web Application Model Request Response
Communication model • Web server cannot distinguish if request is made from same browser or not • Its stateless • http doesn’t store any details how request is made
Different Clients • Web browsers • ftp clients
What is web server? • Webserver hosts website and offers protocol http • It takes request and response • It’s a software to provide services to access internet • Web server executes server side programmes
Example • Facebook login • User request something • Client response something • http protocol is used for communication • Example : • Pdf files, doc files
Http • Its a request – response model or oriented protocol • Http request contains the following: • Request Method • URI • Header Fields • Body
Http Response • Http Response contains: • Result code • Header Fields • Body
Http request Example • www.facebook.com • In Request following are sent: • GET-POST/ • URI = home.html • http protocol • Headers : Host : facebook.com User –Agent : Google Chrome Body : Request parameters
HTTP response Example • Status line : tells if its error or ok response • Response headers : Last modified: some date Date: current date Content type: html/text content length: 50
Dynamic Website • Client Sends a request to server • Server side does some computation and response with html page with result generated of computation • Why dynamic pages and not static?
Dynamic Websites • www.google.com • Results depends on our query • www.facebook.com • Results depends on user login and database
Servlets • Its a java class • Servlets extend webserver to extend its capability • It allows us to compute on webserver and gives us a response Request Response
Servlets • Any class in java can be written in servlets • We don’t have to write http protocol mechanism • Rich set of libraries of java available in servlets • E.g. • JDBC • Multithreading • E.t.c
Servlet Advantages • Rich set of libraries • Built in multithreading – treats every request as multithread rather than creating new process • Portable across operating systems • Security – jvm verifier
Software's Required • Eclipse / net Beans • Tomcat Server • J2SE • J2EE
Servlet Hello World • To write Servlet we need to extend from • HttpServlet • Import javax.servlet.*; • Import javax.servlet.http.*;