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: 4093
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: / 162
PoorBest 

Let’s see how it works. Create 2 new JSP called JstL_Core_Tags_Redirect.jsp and Jstl_Core_Tags_Import.jsp.

Add this to Jstl_Core_Tags_Redirect.jsp

<c:redirect url="index.jsp" />

It is going to redirect the page back to index.jsp

Add this to Jstl_Core_Tags_Import.jsp

<c:import url="index.jsp" />

It will import or include index.jsp after Jstl_Core_Tags_Import.jsp loads.

This is what we get when we run Jstl_Core_Tags_Redirect.jsp. Just type the address as shown in circled area and the page will redirect us back to index.jsp.

 

Image

 

Interesting right? Well, do same thing for Jstl_Core_Tags_Import.jsp. Open browser then type the full address manually and we will get index.jsp is loaded after Jstl_Core_Tags_Import.jsp loads.

 

Image

 

4. Implementation of JSTL Formatting Tags

Now, you should have understood the JSTL core tags very well. As you can see, the JSP is more readable and more maintainable. If you try to achieve all the previous examples using scriptlets, your JSP may be larger in size and much more complex. Well, it is time to move on to the second JSTL tags which is JSTL Formatting tags. Similarly, create a new JSP and name it Jstl_Fmt_Tags.jsp. Add one more link in our existing index.jsp but this time let’s make it in another table to ensure the simplicity of the example.

<table border="1">

<tr>

<td>

<a href="Jstl_Fmt_Tags.jsp">JSTL Formatting Tags</a>

</td>

<td>

Internationalizing and Formatting

</td>

</tr>

</table>

Now, we need to include another JSTL tag. Here is how to import the fmt JSTL taglib directive.

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

Let’s try something interesting on the JSTL internationalization support.

<c:out value="${pageContext.request.locale}" />

Above codes will simply print out our default locale. The value will be retrieved from each client’s specific browser. In IE browser, you can find your Locale on Tools-Internet Options… and then Languages…

 

Image

 

Ok now we need to create properties files under WEB-INF/classes/ directory. These files often called as resource bundle files and should be located under this directory as it will be included in the classpath. If the file is not within the classpath, you will not be able to access it from your application. Normally, resource bundle properties files will be the place to store the language translations.



 
< 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.