JSP and JSTL Tutorials - Tutorial Addendum - Beheading Ambience
| |
Predefined Objects
Now we understand that the Java statements anchored in JSP pages will translated into
_jspService() adjustment of a appropriate Servlet class. In that method, there are
a brace of pre-defined altar accessible for the anchored Java statements:
- out: The achievement beck to aggregate activating data to be alloyed into the final Web
document.
- this: The instance of the appropriate Servlet class.
- request: An HttpServletRequest item apery the appeal accustomed from
the Web browser.
- response: An HttpServletResponse item apery the acknowledgment to be delivered
back to the Web browser.
- session: An HttpSession item apery the abstraction of bond assorted trips
of requests and acknowledgment into a individual action unit.
- application: A ServletContext item apery the abstraction of alignment Servlets
into a individual application.
- config: A ServletConfig object.
- pageContext: A PageContext object.
The afterward JSP page will appearance you added data about those pre-defined objects:
<!--
- ContextInfo.jsp
- Absorb (c) 2002 by Dr. Yang. All rights reserved.
-->
<html><body>
<p>
<b>JSP Page Ambience Information</b><br/>
</p>
<p>
<b>Pre-defined objects:</b><br/>
<%
out.println("out: "+out.getClass().getName()+"<br/>");
out.println("this: "+this.getClass().getName()+"<br/>");
out.println("request: "+request.getClass().getName()+"<br/>");
out.println("response: "+response.getClass().getName()+"<br/>");
out.println("session: "+session.getClass().getName()+"<br/>");
out.println("application: "+application.getClass().getName()
+"<br/>");
out.println("config: "+config.getClass().getName()+"<br/>");
out.println("pageContext: "+pageContext.getClass().getName()
+"<br/>");
%>
</p>
<p>
<b>Information about session:</b><br/>
<i>= pageContext.getSession();</i><br/>
<%
out.println("Class Name: "+session.getClass().getName()+"<br/>");
out.println("Session ID: "+session.getId()+"<br/>");
java.util.Date d = new java.util.Date();
d.setTime(session.getCreationTime());
out.println("Create Time: "+d.toString()+"<br/>");
d.setTime(session.getLastAccessedTime());
out.println("Last Admission Time: "+d.toString()+"<br/>");
out.println("Is Affair New: "+session.isNew()+"<br/>");
%>
</p>
<p>
<b>Information about sessionContext:</b><br/>
<i>= session.getSessionContext();</i><br/>
<%
javax.servlet.http.HttpSessionContext c
= session.getSessionContext();
out.println("Class name: "+c.getClass().getName()+"<br/>");
%>
</p>
<p>
<b>Information about application:</b><br/>
<i>= pageContext.getServletContext();</i><br/>
<%
out.println("Class Name: "+application.getClass().getName()+"<br/>");
out.println("Major Version: "+application.getMajorVersion()+"<br/>");
out.println("Minor Version: "+application.getMinorVersion()+"<br/>");
out.println("Server Info: "+application.getServerInfo()+"<br/>");
out.println("Serlet Ambience Name: "
+application.getServletContextName()+"<br/>");
java.util.Enumeration e = application.getServletNames();
while (e.hasMoreElements()) {
Cord n = (String) e.nextElement();
out.println("Servlet Name: "+n+"<br/>");
}
e = application.getInitParameterNames();
while (e.hasMoreElements()) {
Cord n = (String) e.nextElement();
out.println("Init Constant Name: "+n+"<br/>");
}
%>
</p>
</body></html>
(Continued on next part...)
|
println, session, application, getclass, getname, object, pagecontext, response, class, context, servlet, string, request, representing, information, objects, config, defined, , getname <, getclass getname, object representing, representing the, class name, java util, println class, defined objects, pre defined, information about, pre defined objects, println class name, session getclass getname, application getclass getname, java util date, special servlet class, tutorials tutorial notes, tutorial notes execution, notes execution context, jstl tutorials tutorial, |
Also see ...
i(Continued from antecedent part...)/iOutput: JSP Page Ambience InformationPre defined objects:out: org.apache.jasper.runtime.JspWriterImplthis: org.apache.jsp.Conte
i(Continued from antecedent part...)/iHere is simple JSP page that set accolade in altered ways, CookieDump.jsp: <?xml version="1.0"?<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" ve
Syntactic Elements of a JSP PageThere are two types of data in a JSP page:Template Data: The changeless part, annihilation that will be affected anon to the ac
i(Continued from antecedent part...)/iWhat happens actuality is that the server is apparently sending acknowledgment withcontent type set to text/xml. To fix the problem, we charge to use a directiveelemen
i(Continued from antecedent part...)/iJSP Archetype "CurrentTime.jsp"The afterward archetype has three JSP files alive calm to appearance you how to use "deca
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
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
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
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
i(Continued from antecedent part...)/iUploadSave.jsp Extenuative Uploaded FilesAs you can see from the antecedent section, auctioning uploaded files aback to the br