GRAPHIC JAVAThe evolution of Java Server Pages

GRAPHIC JAVA
The evolution of Java Server Pages

David Geary

Listing 3. A generated servlet.


import java.io.*;
import javax.servlet.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import javax.servlet.http.*;

public class _Date__jsp extends custom.webserver.JavaPage {
  private char []_jsp_contents;
  public void _jspService(HttpServletRequest request,
                             HttpServletResponse response)
                             throws IOException, ServletException {
    PageContext pageContext =
			JspFactory.getDefaultFactory().getPageContext(this,
				request, response, null, true, 8192, true);
    JspWriter out = (JspWriter) pageContext.getOut();
    ServletConfig config = getServletConfig();
    Servlet page = this;
    HttpSession session = pageContext.getSession();
    ServletContext application = pageContext.getServletContext();

    try {
    	out.write(_jsp_string0);
    	out.print(( new java.util.Date() ));
    	out.write(_jsp_string1);
    }
    	catch (Exception e) {
         pageContext.handlePageException(e);
    }
        finally {
           JspFactory.getDefaultFactory().releasePageContext(
        pageContext);
      }
    }
    private static char []_jsp_string0 =
			"<html><title>Date Jsp</title></html>\r\n<body>" +
			"\r\n<h2>Today's Date:</h2>\r\n".toCharArray();
    private static char []_jsp_string1 =
    "\r\n</body>\r\n".toCharArray();
    }

About the Author

David Geary was the lead engineer for the Java Management API GUI toolkit, and is now an independent Java consultant. David is the author of Graphic Java—Mastering the JFC. He can be contacted at sabreware@tri-lakesonline.net.

Featured

Upcoming Events

AppTrends

Sign up for our newsletter.

I agree to this site's Privacy Policy.