Signup · Login
Stardeveloper.com  
Home · Tutorials · Forums · ASP.NET Newsletter Application · Web Hosting Plans · Faisal Khan's Blog · Contact
Search Stardeveloper.com
Newsletter
Enter your email address to receive full length articles at Stardeveloper:


Article Categories
.NET  .NET
  ASP (16)
  ASP.NET (41)
  ADO (16)
  ADO.NET (11)
  COM (6)
  Web Services (4)
  C# (1)
  VB.NET (3)
  IIS (2)

J2EE  J2EE
  JSP (15)
  Servlets (9)
  Web Services (1)
  EJB (4)
  JDBC (4)
  E-Commerce (1)
  J2ME (1)
  Products (1)
  Applets (1)
  Patterns (1)

Main Category  Other
  Website Maintenance (3)
Log In
UserName Or Email:

Password:

Auto-Login:

Hosted by Securewebs.com
 
Home : J2EE : JSP : Examining Java Server Pages in detail
 
Read full length articles at Stardeveloper using Twitter Follow on Twitter Facebook Facebook fan page Email Get Articles via Email RSS Get Articles via RSS Feed
  • <jsp:include>
  • <jsp:forward>
  • <jsp:param>
  • <jsp:plugin>

We now look at them one by one.

i. The <jsp:include> Tag
This jsp:include tag allows inclusion of the content of the given file within the JSP page at the request time. Notice that it is different from the include directive we studied above where the content of the file was included at translation time. It's syntax is as follows :

<jsp:include page="pathToFile" flush="true | false" />

The page attribute contains the path to the given file you want to include ( which can be a JSP page, Servlet or a simple HTML/text file ). Flush attribute should be set to true for compatibility with JSP 1.1. In JSP 1.2 compatible application servers ( e.g, Tomcat 4.0 ) you can set the flush attribute to false.

ii. The <jsp:param> Tag
This tag is used inside the <jsp:include>, <jsp:forward> and <jsp:plugin> tags. It defines and sets different parameters with their values .e.g,

<jsp:include page="file.jsp" flush="true" %>
	<jsp:param name="name" value="Faisal Khan" />
</jsp:include>

In the code above a parameter with the name 'name' and a value of "Faisal Khan" has been provided to the included JSP page; file.jsp. The file.jsp page can access the value of this paramter by :

<%
	String name = request.getParamter("name");
%>

iii. The <jsp:forward> Tag
This tag allows you to forward the control to a given page. It's syntax is as follows :

<jsp:forward page="pathToFile" />

Where pathToFile is the path to the page you want control to be forwarded to. Like <jsp:include> tag you can also use <jsp:param> to provide parameters to the forwarded page.

iv. The <jsp:plugin> Tag
This tag allows you to embed Java applets or beans in a web page. It's syntax is as follows :

<jsp:plugin type="bean | applet" code="className"
	codebase="path to root directory containing classes"
	align="top | middle | bottom | left | right" 
	archives="jar files required for this app"
	height="height in pixels" width="width in pixels"
	hspace="horizontal space in pixels" vspace="vertical space"
	jreversion="the JRE version required"
	name="name of object"
	nspluginurl="URL for Netscape plugin"
	iepluginurl="URL For IE plugin"
>
	<jsp:params>
		<jsp:param name="name" value="value" />
	</jsp:params>
	<jsp:fallback>
		Sorry your browser doesn't support Java applets.
	</jsp:fallback>
</jsp:plugin>

Almost all the attributes for the <jsp:plugin> tag above are self explanatory.

Java Bean Tags
There is one other small group of tags which allow the incorporation of Java beans in a JSP page. We will look Java beans and bean tags in detail in some other article as this topic deserves some more attention.

Summary
In this article we briefly had a look at all of the different elements which constitute a JSP page. We first learned about three types of directives and then moved forward to learn about four types of scripting elements. In the end we discussed what are built-in JSP tags which are provided to us as part of the JSP specification.

Two things that we didn't discuss were :

  • Custom Tags
  • Java Beans

I deliberately left the above two topics because they deserve more attention and don't worry we will be giving them due attention in my next articles.

This article provides a strong foundation for future JSP articles and once you have understood these simple JSP elements, you can move forward to learn about Java beans, custom tags, JDBC, XML and frameworks for web application architectures.


Previous ( 1 Gone )( No Further Pages )

Related Articles
  1. Sending Emails using JavaServer Pages
  2. Installing, Configuring, & Running Tomcat 6.0 Servlet Container on Microsoft Windows, and Developing & Running your first JSP Page
  3. Exception Handling in JSP Pages
  4. Introducing JavaServer Pages
  5. Professional JSP
  6. Combining Servlets, JSP, and JavaBeans
  7. Google on your WAP phone using Java Server Pages

Comments/Questions ( Threads: 3, Comments: 5 )
    Contains 1 or more replies by the Author of this Article.
    Contains 1 or more replies by Faisal Khan.

  1. Java Mail Using JSP and beans
  2. i need the models of javabeans
  3. It's great !!! ( 2 Replies ) This thread contains 1 reply by the Author of this Article. This thread contains 1 reply by Faisal Khan.

Post Comments/Questions

In order to post questions/comments, you must be logged-in. If you are not a member yet, then signup, otherwise login. Once you login then come back to this page and you'll see a form right here which will allow you to post comments/questions.

Please note, one of the benefits of signing up is to be notified immediately by email everytime you receive a reply to the thread you have subscribed.

 
© 1999 - 2010 Stardeveloper.com, All Rights Reserved.