Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
By
Apex TG India Pvt Ltd
Presentation Overview
Introduction
to J2EE
Explain the major technologies within
the J2EE designation
J2EE applications
J2EE servers
http://java.sun.com/java2/
J2EE Technologies
Java Servlets
JSP
EJB
JMS
JDBC
JNDI
JTA / JTS
JavaMail
JAAS
XML
J2EE Components
http://java.sun.com/j2ee/overview3.html
Java Servlets
Servlets are the Java platform technology of
choice for extending and enhancing web servers.
Servlets provide a component-based, platformindependent method for building web-based
applications, without the performance limitations
of CGI programs.
http://java.sun.com/products/servlets/index.html
Java Servlets
Servlets have access to the entire family of Java
APIs, including the JDBCTM API to access enterprise
databases.
Servlets can also access a library of HTTP-specific
calls and receive all the benefits of the mature Java
language, including portability, performance,
reusability, and crash protection
http://java.sun.com/products/servlets/index.html
Anatomy of a Servlet
http://java.sun.com/docs/books/tutorial/servlets/lifecycle/index.html
Anatomy of a Servlet
http://java.sun.com/docs/books/tutorial/servlets/lifecycle/index.html
Anatomy of a Servlet
HTTPServletRequest object
Headers
Query String
Session
Cookies
HTTPServletResponse object
Headers
Status codes
Cookies
Sample Servlet
import java.io.*;
//Apache Tomcat sample code
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter(); out.println("<html>");
out.println("<body>");
out.println("<head>");
out.println("<title>Hello World!</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Hello World!</h1>");
out.println("</body>");
out.println("</html>");
}
}
http://java.sun.com/products/jsp/index.html
Sample JSP
<html>
<!- Apache Tomcat Samples ->
<!-- Copyright (c) 1999 The Apache Software Foundation. All rights reserved.-->
<body bgcolor="white">
<jsp:useBean id='clock' scope='page' class='dates.JspCalendar' type="dates.JspCalendar" />
<font size=4><ul>
<li> Day of month: is <jsp:getProperty name="clock" property="dayOfMonth"/>
<li> Year: is <jsp:getProperty name="clock" property="year"/>
<li> Month: is <jsp:getProperty name="clock" property="month"/>
<li> Time: is <jsp:getProperty name="clock" property="time"/>
<li> Date: is <jsp:getProperty name="clock" property="date"/>
<li> Day: is <jsp:getProperty name="clock" property="day"/>
<li> Day Of Year: is <jsp:getProperty name="clock" property="dayOfYear"/>
<li> Week Of Year: is <jsp:getProperty name="clock" property="weekOfYear"/>
<li> era: is <jsp:getProperty name="clock" property="era"/>
<li> DST Offset: is <jsp:getProperty name="clock" property="DSTOffset"/>
<li> Zone Offset: is <jsp:getProperty name="clock" property="zoneOffset"/>
</ul>
</font>
</body>
</html>