JSP and JSTL Tutorials - Tutorial Addendum - JSP Elements

 31 December 18:00   

    



    



    

(Continued from antecedent part...)

    



    

It s actual absorbing to see the Servlet chic translated from CurrentTime.jsp:

    

 

    

package org.apache.jsp;

    

import javax.servlet.*;

    

import javax.servlet.http.*;

    

import javax.servlet.jsp.*;

    

import org.apache.jasper.runtime.*;

    

import java.util.*;

    

import java.text.*;

    

public chic CurrentTime_jsp extends HttpJspBase {

    

clandestine Date now;

    

clandestine JspWriter out;

    

clandestine abandoned printTime(String tz) throws Throwable {

    

DateFormat df = DateFormat.getInstance();

    

df.setTimeZone(TimeZone.getTimeZone(tz));

    

out.println(tz+": "+df.format(now)+"<br/>");

    

}

    

clandestine changeless java.util.Vector _jspx_includes;

    

changeless {

    

_jspx_includes = new java.util.Vector(1);

    

_jspx_includes.add("/jsp/JvmStamp.jsp");

    

}

    

accessible java.util.List getIncludes() {

    

acknowledgment _jspx_includes;

    

}

    

accessible abandoned _jspService(Http Servlet Request request,

    

Http Servlet Response response)

    

throws java.io.IOException, Servlet Exception {

    

JspFactory _jspxFactory = null;

    

javax.servlet.jsp.PageContext pageContext = null;

    

HttpSession affair = null;

    

Servlet Context appliance = null;

    

Servlet Config config = null;

    

JspWriter out = null;

    

Item page = this;

    

JspWriter _jspx_out = null;

    

try {

    

_jspxFactory = JspFactory.getDefaultFactory();

    

response.setContentType("text/html;charset=UTF-8");

    

pageContext = _jspxFactory.getPageContext(this, request, response,

    

null, true, 8192, true);

    

appliance = pageContext.get Servlet Context();

    

config = pageContext.get Servlet Config();

    

affair = pageContext.getSession();

    

out = pageContext.getOut();

    

_jspx_out = out;

    

out.write("<html>");

    

out.write("<body>");

    

out.write("<p>");

    

out.write("<b>");

    

out.write("Current time in altered time zones:");

    

out.write("</b>");

    

out.write("<br/>");

    

this.out = out;

    

now = new Date();

    

printTime("America/New_York");

    

printTime("America/Los_Angeles");

    

printTime("Asia/Shanghai");

    

printTime("Europe/Paris");

    

printTime("Europe/Moscow");

    

out.write("</p>");

    

out.write("<p>");

    

out.write("<b>");

    

out.write("Current JVM:");

    

out.write("</b>");

    

out.write("<br/>");

    

Cord s;

    

s = "java.vm.name";

    

out.println(s+": "+System.getProperty(s)+"<br/>");

    

s = "java.vm.version";

    

out.println(s+": "+System.getProperty(s)+"<br/>");

    

s = "os.name";

    

out.println(s+": "+System.getProperty(s)+"<br/>");

    

s = "os.version";

    

out.println(s+": "+System.getProperty(s)+"<br/>");

    

out.write("</p>");

    

out.write("<p>");

    

JspRuntimeLibrary.include(request, response, "TimeStamp.jsp", out,

    

false);

    

out.write("</p>");

    

out.write("</body>");

    

out.write("</html>");

    

} bolt (Throwable t) {

    

out = _jspx_out;

    

if (out != absent && out.getBufferSize() != 0)

    

out.clearBuffer();

    

if (pageContext != null) pageContext.handlePageException(t);

    

} assuredly {

    

if (_jspxFactory != null)

    

_jspxFactory.releasePageContext(pageContext);

    

}

    

}

    

}

    



    



    

Couple of absorbing things to understand in this example:

    



        

  • The pre-defined altar like "out" is not accessible in the charge elements.

        

    So I acclimated an instance capricious "out" to canyon the pre-defined "out" to my "printTime()"

        

    method in the acknowledgment element.

        



  •     

  • Since I am using XML format, "<" needs to be replaced by the article name "&lt;"

        

    in any Java statements. During the adaptation process, the article names will be

        

    replaced aback to "<".

        



  •     

  • No Servlet chic was created for JvmStamp.jsp, because its agreeable was included

        

    into CurrentTime.jsp during the adaptation process.

        



  •     

  • "TimeStamp.jsp" was advised abnormally than "JvmStamp.jsp". "TimeStamp.jsp"

        

    was translated apart into a Servlet class. Its account adjustment was alleged

        

    by CurrentTime_jsp.java during execution.

        



  •     



    



    



    

 


Tags: system, class, elements, includes, write, notes, public, tutorial, tutorials, response

 write, pagecontext, printtime, servlet, import, jspxfactory, println, private, response, javax, class, includes, getproperty, system, currenttime, timestamp, request, jspwriter, public, elements, jvmstamp, , write <, system getproperty, java util, jspx includes, javax servlet, currenttime jsp, timestamp jsp, import javax, jspx out, servlet class, jvmstamp jsp, import javax servlet, java util vector, tutorials tutorial notes, jstl tutorials tutorial,

Share JSP and JSTL Tutorials - Tutorial Addendum - JSP Elements:
Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

Permalink
Article In : Computers & Technology  -  jsp