Place your text ad here.
World class data recovery software and renowned raid recovery services
WestNIC provides reliable web hosting services
Free software downloads and drivers download resources
Ahosting.biz reseller hosting, managed dedicated server with 24/7 support
This FAQ is part of the Code Style Help and FAQ section. Use the help request form below if your question is not answered here, but make sure you are asking the right question first.
include directive and action element?
include directive or jsp:include?
@ page include tag?
include directive and action element?
A: The @page include directive in a JSP document is resolved at page translation time, when the servlet container converts the JSP into Java source code and then compiles it. The included file contents may be static HTML fragments and optionally include their own JSP tags and scripts. Each included file is inserted into the flow of the parent JSP document as if it were part of the original, so it is a good way of placing template-style code fragments into numerous pages.
More details available to subscribers:
What's the difference between the include directive and action element?
include directive or jsp:include?
A: When you use the jsp:include tag, the text of a file is inserted into the output stream of the JSP servlet at the point the tag occurs. This insertion occurs at request time and is not parsed for JSP script content, the file content is just copied to the output stream.
More details available to subscribers:
How many servlets are created by the include directive or jsp:include?
@ page include tag?
A: The only way to instantiate a class in an external package is to declare it in an @ page include directive, followed by a constructor statement. Bear in mind that your JSP will be compiled into servlet source code and then a servlet class in turn. The page include directive is translated into an import statement in the servlet source and is the only way to place such statements in the source. If the import statement is not present the servlet will not compile.
As with all Java programs, classes in the package java.lang are imported implicitly, so it is possible to instantiate objects in this package without a page include directive.
A: Tag libraries define a set of JSP tags that may be used in a Web application. The tag library descriptor file is used to declare the tags that belong to a library and the attributes and values they may use. The tag library descriptor is loaded by the servlet container when it starts up so that it can insert the relevant code into JSP documents when they are compiled into servlets.
Tag libraries enable the inclusion of relatively complex Java processing using a syntax that is very similar to HTML, that does not require special knowledge of Java language or programming. Tag libraries can also be re-used in multiple Web applications, hence Sun's Java Standard Tag Library (JSTL).
A: The main difference between the two is that the Java Standard Tag Library (JSTL) is designed for general purposes and custom libraries are written for specific applications.
More details available to subscribers:
What's the difference between standard and custom tag libraries?
A: To configure Tomcat to handle your custom tags, you must create an XML format Tag Library Descriptor (TLD) file and configure the application's web.xml file to load it. A minimal tag library descriptor is given below.
More details available to subscribers:
I get "No such tag ... with prefix Hello", what's up?
A: This error means that a tag attribute in your Tag Library Definition (TLD) is configured to expect a literal attribute value, not a runtime expression, but your JSP document is attempting to pass an expression to the tag attribute. Look up the tag identified in the stack trace and check the value attributed to the element on the relevant line of your JSP document. To fix the problem you have two options, as follows:
More details available to subscribers:
I get "attribute binding does not accept any expressions"!
| Front-end FAQs | Back-end FAQs | Learning Java |
|---|---|---|
See site help for questions about this site, our text ads and sponsored links services.