Skip to main content

JSTL Tutorials Using NetBeans : Part-5

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
It is going to redirect the page back to index.jsp
Add this to Jstl_Core_Tags_Import.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.
Internationalizing and Formatting
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.
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.

Comments

Popular posts from this blog

Java Health Center - Overview and Features

This video highlights the features available in Health Center. Health Center is a low-processor and memory usage diagnostic tool for monitoring the status of a running IBM Java Virtual Machine (JVM). Health Center provides live information and recommendations in each of the following areas: - Classes: information about classes being loaded - Environment: details of the configuration and system of the monitored application - Garbage Collection: information about the Java heap and pause times - Locking: information about contention on inflated locks - Profiling: sampling profile of Java methods including call paths

WebSphere MQ Interview Questions

What is MQ and what does it do? Ans. MQ stands for MESSAGE QUEUEING. WebSphere MQ allows application programs to use message queuing to participate in message-driven processing. Application programs can communicate across different platforms by using the appropriate message queuing software products. What is Message driven process? Ans . When messages arrive on a queue, they can automatically start an application using triggering. If necessary, the applications can be stopped when the message (or messages) have been processed. What are advantages of the MQ? Ans. 1. Integration. 2. Asynchrony 3. Assured Delivery 4. Scalability. How does it support the Integration? Ans. Because the MQ is independent of the Operating System you use i.e. it may be Windows, Solaris,AIX.It is independent of the protocol (i.e. TCP/IP, LU6.2, SNA, NetBIOS, UDP).It is not required that both the sender and receiver should be running on the same platform What is Asynchrony? Ans. With messag...

Java Garbage Collection

Explain Garbage collection mechanism in Java? Garbage collection is one of the most important features of Java. The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused. A Java object is subject to garbage collection when it becomes unreachable to the program in which it is used. Garbage collection is also called automatic memory management as JVM automatically removes the unused variables/objects (value is null) from the memory. Every class inherits finalize() method from java.lang.Object, the finalize() method is called by garbage collector when it determines no more references to the object exists. In Java, it is good idea to explicitly assign null into a variable when no more in use. In Java on calling System.gc() and Runtime.gc(), JVM tries to recycle the unused objects, but there is no guarantee when all the objects will garbage collected. Garbage collection is an automatic pro...