You are here: Articles > Computers & Technology > jsp

 See more articles about "jsp "

JSP and JSTL Tutorials - Tutorial Addendum - JSP Elements



 31 December 18:00   

    



    



    

(Continued from antecedent part...)

    



    



    

JSP Archetype - "CurrentTime.jsp"

    



    

The afterward archetype has three JSP files alive calm to appearance you

    

how to use "decalaration" elements, "include" charge elements

    

and "include" activity elements. Actuality is the capital JSP file, CurrentTime.jsp:

    

 

    

<?xml version="1.0"?>

    

<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2">

    

<!-- CurrentTime.jsp

    

Absorb (c) 2002 by Dr. Yang

    

-->

    

<jsp:directive.page contentType="text/html"/>

    

<html><body>

    

<jsp:directive.page import="java.util.*"/>

    

<jsp:directive.page import="java.text.*"/>

    

<jsp:declaration>

    

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)+"&lt;br/>");

    

}

    

</jsp:declaration>

    

<p>

    

<b>Current time in altered time zones:</b><br/>

    

<jsp:scriptlet>

    

this.out = out;

    

now = new Date();

    

printTime("America/New_York");

    

printTime("America/Los_Angeles");

    

printTime("Asia/Shanghai");

    

printTime("Europe/Paris");

    

printTime("Europe/Moscow");

    

</jsp:scriptlet>

    

</p>

    

<p>

    

<jsp:directive.include file="JvmStamp.jsp"/>

    

</p>

    

<p>

    

<jsp:include page="TimeStamp.jsp"/>

    

</p>

    

</body></html>

    

</jsp:root>

    



    



    

Here is the JSP book acclimated by the cover charge element, JvmStamp.jsp:

    

 

    

<?xml version="1.0"?>

    

<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2">

    

<!-- JvmStamp.jsp

    

Absorb (c) 2002 by Dr. Yang

    

-->

    

<b>Current JVM:</b><br/>

    

<jsp:scriptlet>

    

Cord s;

    

s = "java.vm.name";

    

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

    

s = "java.vm.version";

    

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

    

s = "os.name";

    

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

    

s = "os.version";

    

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

    

</jsp:scriptlet>

    

</jsp:root>

    



    



    

Here is the JSP book acclimated by the cover activity element, TimeStamp.jsp:

    

 

    

<?xml version="1.0"?>

    

<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2">

    

<!-- TimeStamp.jsp

    

Absorb (c) 2002 by Dr. Yang

    

-->

    

<b>Current Time: </b>

    

<jsp:scriptlet>

    

java.util.Date d = new java.util.Date();

    

out.println(d.toString());

    

</jsp:scriptlet>

    

</jsp:root>

    



    



    

Here is what I got by requesting CurrentTime.jsp from IE:

    

 

    

Current time in altered time zones:

    

America/New_York: 12/23/02 9:38 PM

    

America/Los_Angeles: 12/23/02 6:38 PM

    

Asia/Shanghai: 12/24/02 10:38 AM

    

Europe/Paris: 12/24/02 3:38 AM

    

Europe/Moscow: 12/24/02 5:38 AM

    

Current JVM:

    

java.vm.name: Java HotSpot(TM) Applicant VM

    

java.vm.version: 1.3.1_01

    

os.name: Windows 2000

    

os.version: 5.0

    

Current Time: Mon Dec 23 21:38:10 EST 2002

    



    

(Continued on next part...)

    



    



 


 version, println, scriptlet, printtime, directive, elements, system, getproperty, currenttime, current, private, copyright, timestamp, jvmstamp, america, xmlns, , < jsp, jsp root, jsp scriptlet, jsp <, currenttime jsp, system getproperty, jsp directive, html <, directive page, java util, jvmstamp jsp, root here, timestamp jsp, yang <, scriptlet <, current time, jsp page, root xmlns, xmlns jsp, xml version, < xml, jsp file, jsp http, http java, page version, com jsp, sun com, java sun, jsp copyright, jsp page version, jsp root here, jsp http java, jsp directive page, jsp root xmlns, jsp file used, java util date, tutorials tutorial notes, page import java, jstl tutorials tutorial, directive page import, different time zones,

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 ...

JSP and JSTL Tutorials - Tutorial Addendum - JSP Elements
i(Continued from antecedent part...)/iIt s actual absorbing to see the Servlet chic translated from CurrentTime.jsp: package org.apache.jsp;import javax.servlet.*;import javax.ser

JSP and JSTL Tutorials - Tutorial Addendum - Book Upload
This affiliate shows you:What are the requirements to upload files to Web servers.The RFC 1867 addendum of HTML for uploading files.How to address a HTML page

JSP and JSTL Tutorials - Tutorial Addendum - Book Upload
i(Continued from antecedent part...)/iHere is sample HTML page to appearance you how to use Book ascribe acreage and "multipart/form data" encryption type: <?xml version="1.0"?p

JSP and JSTL Tutorials - Tutorial Addendum - Book Upload
i(Continued from antecedent part...)/iOf course, I aswell wrote the UploadForm.jsp to present the book upload anatomy page basedthe settings: <?xml version="1.0"?<jsp:root

JSP and JSTL Tutorials - Tutorial Addendum - Book Upload
i(Continued from antecedent part...)/iUploadSave.jsp Extenuative Uploaded FilesAs you can see from the antecedent section, auctioning uploaded files aback to the br

JSP and JSTL Tutorials - Tutorial Addendum - Book Upload
i(Continued from antecedent part...)/iOn UploadForm page, I called the aforementioned files: File Upload Form:Your email: [_yang@yahoo.com ] Your comments: [I am uploadi

JSP and JSTL Tutorials - Tutorial Addendum - JavaServer Pages (JSP)
What is JSP?JSP is a technology, not a language. It allows Web page authors to put activating datainto a Web certificate with Java statements anchored in appropriate HTML tag

JSP and JSTL Tutorials - Tutorial Addendum - JavaServer Pages (JSP)
i(Continued from antecedent part...)/iYou will aswell see a Java chic file: hello_jsp.class. What happened actuality was that Tomcat, the JSP Web server, has translated hello.jsp in

JSP and JSTL Tutorials - Tutorial Addendum - JSP Accepted Tag Libraries (JSTL)
What is JSTL?JSTL (JSP Accepted Tag Libraries) is a accumulating of JSP custom tags developed by Java Association Process, www.jcp.org. The advertence accomplishing is develo

JSP and JSTL Tutorials - Tutorial Addendum - JSP Accepted Tag Libraries (JSTL)
i(Continued from antecedent part...)/iNow let s see the Servlet chic generated by Bobcat server based on my JSP page with the "c:out" tag. The Servlet chic is amid at localjakarta tomcat 4.1.18workstandalo