home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-tomcat-addon-1.4.9-installer.exe / xml_jsp.class (.txt) < prev    next >
Encoding:
Java Class File  |  2004-05-17  |  3.9 KB  |  101 lines

  1. package org.apache.jsp.xml;
  2.  
  3. import java.io.IOException;
  4. import java.text.DateFormat;
  5. import java.text.SimpleDateFormat;
  6. import java.util.Date;
  7. import java.util.List;
  8. import java.util.Locale;
  9. import java.util.Vector;
  10. import javax.servlet.ServletConfig;
  11. import javax.servlet.ServletContext;
  12. import javax.servlet.ServletException;
  13. import javax.servlet.http.HttpServletRequest;
  14. import javax.servlet.http.HttpServletResponse;
  15. import javax.servlet.http.HttpSession;
  16. import javax.servlet.jsp.JspFactory;
  17. import javax.servlet.jsp.JspWriter;
  18. import javax.servlet.jsp.PageContext;
  19. import javax.servlet.jsp.SkipPageException;
  20. import org.apache.jasper.runtime.HttpJspBase;
  21. import org.apache.jasper.runtime.JspSourceDependent;
  22.  
  23. public final class xml_jsp extends HttpJspBase implements JspSourceDependent {
  24.    private static Vector _jspx_dependants;
  25.  
  26.    String getDateTimeStr(Locale l) {
  27.       DateFormat df = SimpleDateFormat.getDateTimeInstance(2, 2, l);
  28.       return df.format(new Date());
  29.    }
  30.  
  31.    public List getDependants() {
  32.       return _jspx_dependants;
  33.    }
  34.  
  35.    public void _jspService(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
  36.       JspFactory _jspxFactory = null;
  37.       PageContext pageContext = null;
  38.       HttpSession session = null;
  39.       ServletContext application = null;
  40.       ServletConfig config = null;
  41.       JspWriter out = null;
  42.       JspWriter _jspx_out = null;
  43.       PageContext _jspx_page_context = null;
  44.  
  45.       try {
  46.          _jspxFactory = JspFactory.getDefaultFactory();
  47.          response.setContentType("text/html;charset=UTF-8");
  48.          pageContext = _jspxFactory.getPageContext(this, request, response, (String)null, true, 8192, true);
  49.          _jspx_page_context = pageContext;
  50.          application = pageContext.getServletContext();
  51.          config = pageContext.getServletConfig();
  52.          session = pageContext.getSession();
  53.          out = pageContext.getOut();
  54.          out.write("<html>");
  55.          out.write("<head>");
  56.          out.write("<title>");
  57.          out.write("Example JSP in XML format");
  58.          out.write("</title>");
  59.          out.write("</head>");
  60.          out.write("<body>");
  61.          out.write("\nThis is the output of a simple JSP using XML format. \n");
  62.          out.write("<br/>");
  63.          out.write("<div>");
  64.          out.write("Use a jsp:scriptlet to loop from 1 to 10: ");
  65.          out.write("</div>");
  66.  
  67.          for(int i = 1; i <= 10; ++i) {
  68.             out.println(i);
  69.             if (i < 10) {
  70.                out.println(", ");
  71.             }
  72.          }
  73.  
  74.          out.write("\n  <br><br>\n");
  75.          out.write("<div align=\"left\">");
  76.          out.write("\n  Use a jsp:expression to write the date and time in the browser's locale: \n  ");
  77.          out.print(this.getDateTimeStr(request.getLocale()));
  78.          out.write("</div>");
  79.          out.write("\n  <p>This sentence is enclosed in a jsp:text element.</p>\n");
  80.          out.write("</body>");
  81.          out.write("</html>");
  82.       } catch (Throwable t) {
  83.          if (!(t instanceof SkipPageException)) {
  84.             if (_jspx_out != null && _jspx_out.getBufferSize() != 0) {
  85.                _jspx_out.clearBuffer();
  86.             }
  87.  
  88.             if (_jspx_page_context != null) {
  89.                _jspx_page_context.handlePageException(t);
  90.             }
  91.          }
  92.       } finally {
  93.          if (_jspxFactory != null) {
  94.             _jspxFactory.releasePageContext(_jspx_page_context);
  95.          }
  96.  
  97.       }
  98.  
  99.    }
  100. }
  101.