This essay developed out of conversations I've had with several other programmers about why Java smelled suspicious. It's not a critique of Java!
Sycorax - complete tutorials
Programming Tutorials
" Java provides the industry - software companies and customer alike , an opportunity to create a true open computing environment where software is portable,
and customers benefit from increase competition. "
Java and the Future
December 1, 2008-LEJB 3.1: EJB New and Improved!
The EJB 3.0 specification was a huge improvement from what you were used to in the early versions of EJB. Available as an early draft, EJB 3.1 has many more features and is even easier to use.
December 1, 2008-Should Java Assert that Network I/O Can't Occur on the UI Thread?
Doing network I/O on the user interface (UI) thread is bad. Most developers know that and can tell you why; unfortunately, it's still done.
Register now to recieve special alert and latest technology news!
JSP Implicit Variables And JSP Implicit Objects
To simplify code in JSP expressions and scriptlets, you are supplied with nine automatically defined variables, sometimes called implicit objects. The available variables are request, response, out, session, application, config, pageContext, page and exception. Details for each are given below.
1) request
Protocol dependent subtype of javax.servlet.ServletRequest. This is the HttpServletRequest associated with the request, and lets you look at the request parameters (via getParameter), the request type (GET, POST, HEAD, etc.), and the incoming HTTP headers (cookies, Referer, etc.). Strictly speaking, request is allowed to be a subclass of ServletRequest other than HttpServletRequest, if the protocol in the request is something other than HTTP. This is almost never done in practice.
<%
String path = request.getContextPath();
String name = request.getParameter("name");
%>
2) response
Protocol dependent subtype of javax.servlet.ServletResponse. This is the HttpServletResponse associated with the response to the client. Note that, since the output stream (see out below) is buffered, it is legal to set HTTP status codes and response headers, even though this is not permitted in regular servlets once any output has been sent to the client.
3) out
An object of type javax.servlet.jsp.JspWriter. This is the PrintWriter used to send output to the client. However, in order to make the response object (see the previous section) useful, this is a buffered version of PrintWriter called JspWriter. Note that you can adjust the buffer size, or even turn buffering off, through use of the buffer attribute of the page directive. This was discussed in Section 5. Also note that out is used almost exclusively in scriptlets, since JSP expressions automatically get placed in the output stream, and thus rarely need to refer to out explicitly.
<html> <body>
<% out.println("Hello !"); %>
</body></html>
4) session
An object of type javax.servlet.http.HttpSession.This is the HttpSession object associated with the request. Recall that sessions are created automatically, so this variable is bound even if there was no incoming session reference. The one exception is if you use the session attribute of the page directive (see Section 5) to turn sessions off, in which case attempts to reference the session variable cause errors at the time the JSP page is translated into a servlet.
5) application
An object of type javax.servlet.ServletContext.
This is the ServletContext as obtained via getServletConfig().getContext().
<% javax.servlet.RequestDispatcher rd;
rd = application.getRequestDispatcher("/NextPage.jsp");
rd.forward(request, response);
%>
6) config
This is the ServletConfig object for this page. An object of type javax.servlet.ServletConfig.
The ServletConfig for this JSP page. Has a page scope.
7) pageContext
A PageContext is an object that provides a context to store references to objects used by the page, encapsulates implementation-dependent features, and provides convenience methods. A JSP page implementation class can use a PageContext to run unmodified in any compliant JSP container while taking advantage of implementation-specific improvements like high performance JspWriters.
public abstract class PageContext extends JspContext {
public abstract java.lang.Exception getException();
public abstract java.lang.Object getPage(); // instance of Servlet
public abstract javax.servlet.ServletRequest getRequest();
public abstract javax.servlet.ServletResponse getResponse();
public abstract javax.servlet.ServletConfig getServletConfig();
public abstract javax.servlet.ServletContext getServletContext();
public abstract javax.servlet.http.HttpSession getSession();
public abstract void handlePageException(java.lang.Exception e);
public abstract void include(java.lang.String relativeUrlPath);
public abstract void forward(java.lang.String relativeUrlPath);
}
8) page
This is simply a synonym for this, and is not very useful in Java. It was created as a placeholder for the time when the scripting language could be something other than Java. Page Class (java.lang.Object) Refers to the page's servlet instance.
9) exception
An object of type java.lang.Throwable.
The uncaught Throwable that resulted in the error page being invoked. Has a page scope.
A JSP is considered an Error Page if it sets the page directive's isErrorPage attribute to true. If a page has isErrorPage set to true, then the exception implicit scripting language variable of that page is initialized.
error.jsp:
<%@ page isErrorPage="true" %>
...
<%= exception.getMessage() %> <br>
With the following stack trace: <br>
<%
ByteArrayOutputStream baos = new ByteArrayOutputStream();
exception.printStackTrace(new PrintStream(baos));
out.print(baos);
%>
<< UNDERSTANDING THE TRANSLATION PROCESS || UNDERSTANDING JSP PAGE SCOPES >>

