11. Dynamic (deep) Web
• Dynamic pages don’t exist before the request
comes in.
• It’s like making an HTML page out of air.
– request comes in,
– helper app “writes” the HTML, and
– web server gets it back to the client.
12. Common Gateway Interface (CGI)
• a standard method for web servers software
to delegate the generation of web pages to
executable files.
• Such files are known as CGI scripts
– they are programs,
• often stand-alone applications,
• usually written in a scripting language.
15. What’s wrong with CGI?
• Logical
– Java is suppose to be the language of the internet
• Performance
– Light-weight
– Easy thread manipulation
• Productivity
– J2EE
24. What a Container offers?
• Help you to concentrate on your business logic
than programming details
– Communication
– Lifecycle Management
– Multithreading Support
– Declarative Security
– JSP Support
26. Back to the code (servlet.java)
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class Ch1Servlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException {
PrintWriter out = response.getWriter();
java.util.Date today = new java.util.Date();
out.println(“<html> “ +
“<body>” +
“<h1 align=center>HF’s Chapter1 Servlet</h1>” +
“<br>” + today + “</body>” + “</html>”);
}
}
27. Questions
• Where service() comes from?
• How the container finds the correct servlet?
• Does the URL define where exactly the servlet
is?
• Possible answers
– The user gives precise URL
– The container’s tool does the mapping
– We store the mapping to the properties table
30. Map URLs top Servlet with DD
Deployment
Descriptor (DD)
has 2 elements
<web-app ...>
<servlet>
<servlet-name>Internal name 1</servlet-name>
<servlet-class>foo.Servlet1</servlet-class>
</servlet>
<servlet>
<servlet-name>Internal name 2</servlet-name>
<servlet-class>foo.Servlet2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Internal name 1</servlet-name>
<url-pattern>/Public1</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Internal name 2</servlet-name>
<url-pattern>/Public2</url-pattern>
</servlet-mapping>
</web-app>
31. Manipulate without touching with DD
• Minimizes touching source code that has already
been tested.
• fine-tune your app’s capabilities, even if you
don’t have the source code.
• adapt your application to different resources (like
databases), without having to recompile and test
any code.
• maintain dynamic security info like access control
lists and security roles.
• non-programmers may modify and deploy your
web applications.