001    package jsp.xml;
002    
003    import javax.servlet.*;
004    import javax.servlet.http.*;
005    import javax.servlet.jsp.*;
006    import java.util.Date;
007    import java.util.Locale;
008    import java.text.*;
009    
010    public final class xml_jsp extends org.apache.jasper.runtime.HttpJspBase
011        implements org.apache.jasper.runtime.JspSourceDependent {
012    
013    
014      String getDateTimeStr(Locale l) {
015        DateFormat df = SimpleDateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, l);
016        return df.format(new Date());
017      }
018    
019      private static java.util.List _jspx_dependants;
020    
021      public Object getDependants() {
022        return _jspx_dependants;
023      }
024    
025      public void _jspService(HttpServletRequest request, HttpServletResponse response)
026            throws java.io.IOException, ServletException {
027    
028        JspFactory _jspxFactory = null;
029        PageContext pageContext = null;
030        HttpSession session = null;
031        ServletContext application = null;
032        ServletConfig config = null;
033        JspWriter out = null;
034        Object page = this;
035        JspWriter _jspx_out = null;
036        PageContext _jspx_page_context = null;
037    
038    
039        try {
040          _jspxFactory = JspFactory.getDefaultFactory();
041          response.setContentType("text/html;charset=UTF-8");
042          pageContext = _jspxFactory.getPageContext(this, request, response,
043                            null, true, 8192, true);
044          _jspx_page_context = pageContext;
045          application = pageContext.getServletContext();
046          config = pageContext.getServletConfig();
047          session = pageContext.getSession();
048          out = pageContext.getOut();
049          _jspx_out = out;
050    
051          out.write("<html>");
052          out.write("<head>");
053          out.write("<title>");
054          out.write("Example JSP in XML format");
055          out.write("</title>");
056          out.write("</head>");
057          out.write("<body>");
058          out.write("\nThis is the output of a simple JSP using XML format. \n");
059          out.write("<br/>");
060          out.write("<div>");
061          out.write("Use a jsp:scriptlet to loop from 1 to 10: ");
062          out.write("</div>");
063    
064    // Note we need to declare CDATA because we don't escape the less than symbol
065    
066      for (int i = 1; i<=10; i++) {
067        out.println(i);
068        if (i < 10) {
069          out.println(", ");
070        }
071      }
072    
073          out.write("\n  <br><br>\n");
074          out.write("<div align=\"left\">");
075          out.write("\n  Use a jsp:expression to write the date and time in the browser's locale: \n  ");
076          out.print(getDateTimeStr(request.getLocale()));
077          out.write("</div>");
078          out.write("\n  <p>This sentence is enclosed in a jsp:text element.</p>\n");
079          out.write("</body>");
080          out.write("</html>");
081        } catch (Throwable t) {
082          if (!(t instanceof SkipPageException)){
083            out = _jspx_out;
084            if (out != null && out.getBufferSize() != 0)
085              out.clearBuffer();
086            if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
087          }
088        } finally {
089          if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
090        }
091      }
092    }