Home arrow Java & J2EE arrow Page 7 - The JSP Files (part 1): Purple Pigs In A Fruitbasket

Alphabet Soup For The Soul - Java

Get to grips with Java Server Pages with this introductorytutorial and find out how to use one of the more powerful server-sidelanguages around. This first part explains the history and basics of JSPdocuments, and also illustrates variables, includes and the String object.

TABLE OF CONTENTS:
  1. The JSP Files (part 1): Purple Pigs In A Fruitbasket
  2. Studying The Foundations
  3. Java In A Teacup
  4. Enter John Doe
  5. Putting Two And Two Together
  6. Basket Case
  7. Alphabet Soup For The Soul
By: Vikram Vaswani and Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 9
February 07, 2001

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
If you've used C before, you're probably already familiar with the "include" directive that appears near the beginning of every C program. JSP supports an equivalent include() function, which does much the same thing. Take a look at this simple example:


<html> <head> <title> Thought For The Day</title> </head> <body> Thought For The Day: <br> <%@ include file="thought.html" %> </body> </html>

[thought.html]

Ever wonder if illiterate people get the full effect of alphabet soup?

In this case, JSP will automatically read the contents of the file "thoughts.html", and display a composite page which looks like this:

<html> <head> <title> Thought For The Day</title> </head> <body> Thought For The Day: <br> Ever wonder if illiterate people get the full effect of alphabet soup? </body> </html>

A very useful and practical application of the include() function is to use it to include a standard footer or copyright notice across all the pages of a Web site, like this:

<html> <head> </head> <body> ...your HTML page... <br> <%@ include file="footer.html" %> </body> </html>

where "footer.html" contains

<font size=-1 face=Arial>This material copyright Melonfire, 2001. All rights reserved.</font>

Now, this footer will appear on each and every page that contains the include() statement above - and, if you need to change the message, you only need to edit the single file named "footer.html"!

And that's about it for this week. We've shown you the basic building blocks of JSP, and next time, we'll be using those fundamental concepts to demonstrate JSP's control structures. Don't miss it!

 
 
>>> More Java & J2EE Articles          >>> More By Vikram Vaswani and Harish Kamath, (c) Melonfire
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

JAVA & J2EE ARTICLES

- More Java Bugs Lead to More Attacks
- Oracle's Java One Brings News, Surprises
- Oracle Patches Java Runtime Environment
- Apple Syncs Java Update with Oracle
- Spring 3.1 Java Development Framework Compat...
- Jelastic Java PaaS Availability and Pricing ...
- NetBeans 7.1 Released, Supports JavaFX 2
- SolarWinds Releases Newest Version of Java M...
- Free Monitoring Tool for Java Apps on Heroku
- Heroku Adds JCloud Platform Support, Java 7 ...
- Java SE 8 Speculation in Full Swing
- Java SE 7 Now Available
- New JVM Language and Java Reporting Tool
- Java 7 Release Update and New Eclipse Toolkit
- The Best Java Netbeans IDE Plugins

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: