Web Hosting Java, JSP, Tomcat 6, J2EE, Servlets, Struts, Jboss
JavaSercer Pages 5.1.1 Using JSP Directives The first
November 30, 2006 on 7:41 am | In Java |JavaSercer Pages 5.1.1 Using JSP Directives The first line in Example 5.1 is a JSP directive element. Directives are used to specify attributes of the page itself, primarily those that affect how the page is converted into a Java servlet. There are three JSP directives: page, include, and taglib. In this example, we’re using only the page directive. We’ll see the others later. JSP pages typically start with a page directive that specifies the scripting language and the content type for the page: <%@ page language="java" contentType="text/html" %> A JSP directive element starts with a directive-start identifier (<%@ ) followed by the directive name (e.g., page) and directive attributes, and ends with %>. A directive contains one or more attribute name/value pairs (e.g., language=”java”). Note that JSP element and attribute names are case-sensitive, and in most cases the same is true for attribute values. For instance, the language attribute value must be java, not Java. All attribute values must also be enclosed in single or double quotes. The page directive has many possible attributes. In Example 5.1, two of them are used: language and contentType. The language attribute specifies the scripting language used in the page. The JSP reference implementation (the Tomcat server) supports only Java as a scripting language.3 java is also the default value for the language attribute, but for clarity you may still want to specify it. Other JSP implementations support other languages besides Java, and hence allow other values for the language attribute. For instance, both JRun (http://www.allaire.com) and Resin (http://www.caucho.com) support JavaScript in addition to Java. The contentType attribute specifies the type of content the page produces. The most common values are text/html for HTML content and text/plain for preformatted, plain text. But you can also specify other types, such as text/xml for browsers that support XML or text/vnd.wap.wml for devices like cellular phones and PDAs that have built-in Wireless Markup Language (WML) browsers. If the content generated by the page includes characters requiring a charset other than ISO-8859-1 (commonly known as Latin-1), you need to specify that charset with the contentType attribute. We’ll look at the details of charsets in Chapter 11. 5.1.2 Using Template Text Besides JSP elements, notice that the page shown in Example 5.1 contains mostly regular HTML: …
… The current time at the server is:- Date: …
- Month: …
- Year: …
- Hours: …
- Minutes: …
In JSP parlance, this is called template text. Everything that’s not a JSP element, such as a directive, action, or scripting element, is template text. Template text is sent to the browser as-is. This means you can use JSP to generate any type of text-based output, such as XML, WML, or even plain text. The JSP container doesn’t care what the template text is. 3 In fact, Java is the only scripting language formally supported in the JSP specification, but the specification leaves room for other languages to be supported. page 44
Note: If you are looking for cheap and inexpensive provider to host and run your tomcat application check Actions tomcat hosting services
No Comments yet
Sorry, the comment form is closed at this time.
...I
just wanted to take the time to say "Thank you!" for our new webmail
system. It's great! Thanks for taking such good care of us.
Thanks
for helping me out. Just for the record, Webhostingjava.net has been a great
web host! So far your support and handling of questions has far
exceeded that of a "larger web hosting company".
I
would like to thank you for helping me with my domain...You have
shown me great patience and professionalism. I would not hesitate to
recommend you to my clients.