Chapter 6
The Server Side
- Techniques for Generating Dynamic Web Content
- CGI scripts in C, Perl, or VB
- Server-side includes
- Apache with mod_perl
- NSAPI (Netscape proprietary)
- ISAPI (Microsoft proprietary)
- Java Servlets
- Server-side JavaScript (Netscape)
- Active Server Pages (ASP, Microsoft)
- Cold Fusion (Allaire)
- Java Server Pages (JSP)
- APIs for generating XML
- Simple API for XML (SAX) from
xml.org
- Languages, tools, environments from
Microsoft
- Document Object Model (DOM) from
W3C
- For XML, the most popular Java API is the DOM
- How Java servlets run
- Class libraries load as needed from the Java VM into the web server
- The web server redirects URLs to the appropriate servlets
- Web Application Resource (WAR) files are an emerging standard
- WAR = Zip file of classes with xml-based registration information
- Built by the J2EE deployment tool
- Drawbacks of the servlet approach
- HTML is embedded in Java code,
e.g. out.write("<br>");
- Even a small change requires recompile and reload
- HTML editors cannot be used
- Hard to add web-designers to the development team
- Edit/compile/run demands IDE
- Installation is tricky
- Each servlet must be registered
- Improved approach: Java Server Pages (JSP)
- JSP files are HTML with embedded Java, e.g.
<% any valid java %>
- JSP files can also have embedded JSP actions, e.g.
<jsp:include somefile>
inserts data in web page from file in real time
- JSP files can invoke Java methods ("beans"), e.g.
<jsp:useBean id="LookupPrice" scope="session"
class="com.keller.xmlsamples.LookupPrice" >
runs LookupPrice which could involve
business logic, database access, etc.
- Automatic compile and run (like scripting)
- Here's how:
- Make .jsp files
- Move them to the public_html directory
- HTML editors and web designers can be used
- No IDE is needed
- Add the filename to the URL,
e.g. http://localhost:8000/tryme.jsp
- Edit your files at will; in your browser
you always see the latest
- Resources: