January 10th, 2008
file attribute is a relative URL. A few caveats concerning the use of the include directive are in order. First, be aware that the file to be included may (and usually does) contain JSP code. If the to-be-included file contains page directives, the restriction about the multiple occurrences of page directive attributes applies. In other words, you cannot have an included file contain a page directive with an attribute already coded in the JSP page (except the import attribute). Another caveat is that when you change an included file, you must update all the JSP files that include the changed file. What you need is a JSP or server command that tells the JSP translator to retranslate, but such a command is not currently available. The JSP translator detects when JSP pages require translation based on modification dates. An admittedly primitive but effective workaround is to change a comment in your pages that uses included files to force a retranslation. Later in this chapter, in the section titled Coding JSP Standard Actions, you ll read about the Here, the uri attribute provides an absolute uri containing the code that implements the custom tag s behaviors. The value of the uri attribute can be an absolute (shown above) or relative reference. The prefix attribute associates the custom tag coded in the JSP page with the library name coded as a value of the uri attribute. Note The term uri means Universal Resource Identifier. Think of a uri as a URL or a file reference. The following is an example of a custom tag from http://joestags.tld referenced by the value of the prefix attribute coded in the taglib directive:
Need a managed web hosting provider to help maintain your website? Our web hosting service is the preferred choice of thousands of demanding customers.
Posted in JSP and Java On The Edge | No Comments »
January 9th, 2008
The language Attribute The language attribute indicates the programming language used in scripting the JSP page. The JSP specification requires that a JSP implementation support a value of java for the language attribute. However, other JSP implementations may, and do, support other values for the language attribute. The session Attribute The session attribute indicates whether or not the JSP page uses HTTP sessions. A value of true means that the JSP page has access to a builtin object called session; a value of false means that the JSP page cannot access the builtin session object. Put another way, the following directive allows the JSP page to use any of the builtin object session methods, such as session.getCreationTime() or session.getLastAccessTime(): <%@ page session="true" %> When the session attribute has a value of false, any attempt to access the builtin object session causes an error during JSP to servlet translation. In Chapter 5, JSP Web Sessions, sessions are covered in detail. You should recall that an advantage of using servlets over traditional CGI is that servlets allow for sessions that maintain information about the client across multiple Web pages whereas CGI does not. To wrap up the plethora of attributes for the page directive, I want to note again that these attributes do not direct any output to the eventually displayed page. You may code multiple page directives in your JSP page, but, with the exception of the importattribute, attributes can appear at most once in the page. In addition, you may code more than one attribute in a single page directive, with some combinations (such as buffer=”none” and autoFlush=”false”) not permitted. JSP has two other directives: the include and the taglib directives, which are covered in the following two sections. The include Directive You probably have an idea of the purpose of the include directive. The include directive enables you to bring external code into your JSP at the point of reference. The syntax is as follows: <%@ include file="relativeURL" %> Unlike page directives, the placement of the include directive is critical. The JSP translator copies the code stored at relativeURL into your JSP page starting at the location of the include directive. The URL specification in the value of the
Our facility is located in Orlando, Florida. Our Orlando web hosting data center gives you assurance that your website will work smoothly . Check more in Orlando Web Hosting.
Posted in JSP and Java On The Edge | No Comments »
January 8th, 2008
Different servers may import additional classes, but the preceding list of classes is required to have a functioning JSP environment. You should not rely on your JSP pages having access to classes other than the ones listed without importing the classes yourself! Wouldn t you be embarrassed if your carefully coded JSP pages executed perfectly on server A but choked big time when the company switched to server B, a different Java-enabled server? The following example allows you to code unqualified references in a JSP page for classes in somePackage: <%@ page import="somePackage.*" %> The import attribute is the only attribute that may be coded multiple times in a JSP. Be advised that different Web servers use different directory structures. Therefore, in all likelihood, server A may force you to store your custom classes in a different directory than server B. Some servers require that you store classes used by your JSP pages in a different directory than the directory used to store custom classes for your servlets. The moral of the story is that a cursory glance at the server documentation is worth an hour of directory code examination and trial and error. The info Attribute The info attribute enables you to make a string available to your JSP pages by invoking the JSP page implementation of the Servlet.getServletInfo() method. The string can be pretty much anything you desire. The following is a coding example: <%@ page info="This JSP Page Written By Lou Marco" %> The isThreadSafe Attribute The isThreadSafe attribute lets the JSP container know how to dispatch requests to the page. The value of this attribute is a boolean. When the value is false, the JSP container dispatches one request at a time; when the value is true, the JSP container dispatches all outstanding requests simultaneously. Servlets usually create a thread per user request. Multiple requests result in the servlet dispatching multiple threads, each thread accessing the service() method of the same servlet. The underlying assumption is that the servlet is thread safe. The servlet synchronizes access to data so that threads do not “step on” each other. Assigning a value of true to isThreadSafe does not make your code thread safe. The isThreadSafe attribute is merely a statement about your code s ability to handle multiple threads. Although you should write your code to assume correct execution in a multithreaded environment, you may encounter a situation in which a class you need to use is not thread safe. Hence, you may, at times, code a value of false for the isThreadSave attribute. The default value is true.
Try discount web hosting services, our team’s aim is to offer the best possible web hosting services, at the lowest possible price.
Posted in JSP and Java On The Edge | No Comments »
January 7th, 2008
to the error page. Since JSP error pages are meant to inform on uncaught exceptions, you ll use error pages to report on such exceptions rather than attempt recovery. The JSP page MyErrorPage.jsp must have a page directive with the isErrorPage attribute set to true. The isErrorPage Attribute The isErrorPage attribute indicates whether or not the JSP page is the URL coded in another JSP page s errorPageattribute. The value of isErrorPage is either true or false. The default value of the isErrorPage attribute is false. The extends Attribute The extends attribute specifies a superclass that the generated servlet must extend. For example, the following directive directs the JSP translator to generate the servlet such that the servlet extends somePackage.SomeClass: <%@ page extends="somePackage.SomeClass" %> Do you see a potential problem with coding a value for the extends attribute? The server may be using a superclass already, or may require that generated servlets extend another, different superclass than the superclass coded as a value for the extends attribute. If you use the extends attribute, be careful. The import Attribute The import attribute serves the same function as, and behaves like, the Java import statement. Classes coded as values for the import attribute are made known to the generated servlet. If you do not code any page directives with import attributes, the generated servlet imports, at a minimum, the following classes: l java.lang.* l javax.servlet.* l javax.servlet.jsp.* l javax.servlet.http.*
Get account with us and you will get completely access to our free web templates database with over 10.000 templates in it to build your website.Don’t wait, go and check free web templates.
Posted in JSP and Java On The Edge | No Comments »
January 6th, 2008
Figure 4-1: Internet Explorer asks you what to do with this MIME type. Were you to open the file from its present location, Internet Explorer would display the file as a Word document. Were you to save the file, Windows would save the file as a Word document. Netscape would behave in a similar fashion. You can set a character set for encoding as the following example illustrates: <%@ page contentType="TYPE=text/plain;CHARSET=ISO-8859-1" %> Set the type to plain text using the character set ISO-8859-1. The errorPage Attribute The errorPage attribute defines another JSP page as one that handles unchecked runtime exceptions. The value of the errorPage attribute is a relative URL. Note Relative URLs, when coded with /as the first character (called a context-relative path), are referenced from the application; when coded without / as the first character, they are referenced from the JSP page. You cannot code an absolute URL reference in JSP pages. For example, the following directive displays MyErrorPage.jsp when all uncaught exceptions are thrown: <%@ page errorPage="MyErrorPage.jsp" %> MyErrorPage.jsp is stored in the same directory as the page containing the above page directive. If you code the directive as follows: <%@ page errorPage="/MyErrorPage.jsp" %> then MyErrorPage is stored in the root directory of the application. You can use the setAttribute() method of class javax.servlet.jsp.ServletException to pass the exception object
We feature a web hosting shopping cart and live support solution. Just try our web hosting shopping cartwhich provides a secure way of obtaining payments through your website.
Posted in JSP and Java On The Edge | No Comments »