java left logo
java middle logo
java right logo
 

Home arrow Java Tutorials arrow Introduction to JSTL using NetBeans
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4100
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
Introduction to JSTL using NetBeans E-mail
User Rating: / 163
PoorBest 

3. Implementation of JSTL Core Tags


First, let’s make a new JSP page. Right click on Web Pages folder, New and JSP…

 

Image

 

Image

 

Then a new dialog will show up as displayed above. Let’s call it Jstl_Hello_World.jsp. Then click Finish to create the jsp. Now we have 2 JSPs – index.jsp and Jstl_Hello_World.jsp.

We will create a table in index.jsp for the sample of this tutorial. Place these codes inside the tag <body> in index.jsp

<table border="1">

<tr>

<td>

<a href="Jstl_Hello_World.jsp">Hello World!</a>

</td>

<td>

Print out String "Hello World!"

</td>

</tr>

</table>

Now for the Jstl_Hello_World.jsp, we are going to write some JSTL tags to print out the sentence “Hello World”. Do not forget to uncomment the taglib directive for the JSTL library.

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<c:out value="Hello World!" />

The above codes simply print the sentence “Hello World” to the JSP.

 

<c:set var="sentence" value="Hello World with <c:set/>" />

<c:out value="${sentence}" />

Above codes will do similar thing. The difference is that the sentence was stored into a variable named “sentence” via <c:set> tag and then display it from by using ${variable_name}

<c:remove var="sentence" />

<c:out value="${sentence}" />

The tag <c:remove> works in opposite with <c:set>. In the above codes, the <c:out> will not print anything out anymore because the variable called “sentence” has been removed.


Press Shift+F11 to build the project and F6 to run. We will see something like this for the index.jsp. We may click the “Hello World” link to see our first JSTL tag in action.

 

Image

 

And this is the result after we click the link.

 

Image

 

Ok, we have completed our first Hello World JSTL. Now let’s move on to the logical JSTL core tags. We need to create another link in our index.jsp. The link will contain 3 parameters which hold some values which are boolean, string and numeric. We are goint to see a simple demonstration on how we are supposed to use logical JSTL core tags.



 
< Prev   Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.