Académique Documents
Professionnel Documents
Culture Documents
javawithease
Java EE Containers
importjava.io.*;
importjavax.servlet.*;
importjavax.servlet.http.*;
publicclassHelloWorldextendsHttpServlet{
publicvoiddoGet(HttpServletRequestrequest,HttpServle
tResponseresponse)throwsServletException,IOException
{
response.setContentType("text/html");
PrintWriterpw=response.getWriter();
pw.println("<html>");
pw.println("<head><title>HelloWorld</title></title>");
pw.println("<body>");
pw.println("<h1>HelloWorld</h1>");
pw.println("</body></html>");
}}
<web-app>
<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>
</web-app>
JSP Declarations:
A declaration declares one or more variables or
methods that you can use in Java code later in the JSP
file. You must declare the variable or method before
you use it in the JSP file.
Following is the syntax of JSP Declarations:
JSP Expression:
A JSP expression element contains a scripting
language expression that is evaluated,
converted to a String, and inserted where the
expression appears in the JSP file.
Following is the syntax of JSP Expression:
<%=
expression
%>
The Scriptlet:
A scriptlet can contain any number of JAVA
language statements, variable or method
declarations, or expressions that are valid in the
page scripting language.
Following is the syntax of Scriptlet:
JSP Comments:
JSP comment marks text or statements that the
JSP container should ignore. A JSP comment is
useful when you want to hide or "comment out"
part of your JSP page.
Following is the syntax of JSP comments:
<HTML>
<BODY>
<FORM METHOD=POST ACTION="SaveName.jsp">
What's your name? <INPUT TYPE=TEXT
NAME=username SIZE=20><BR>
What's your e-mail address? <INPUT TYPE=TEXT
NAME=email SIZE=20><BR>
What's your age? <INPUT TYPE=TEXT NAME=age
SIZE=4>
<P><INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>
Benefits of EJB
EJB simplifies the development of small and
large enterprise applications. The EJB container
provides system-level services to enterprise
beans, the bean developer can just concentrate
on developing logic to solve business
problems.
Session Bean
Entity Bean
Message-Driven Bean