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

Asynchronous Vs. Synchronous Communications

Synchronous (One thread):   1 thread -> |<---A---->||<----B---------->||<------C----->| Synchronous (multi-threaded):   thread A -> |<---A---->| \ thread B ------------> ->|<----B---------->| \ thread C ----------------------------------> ->|<------C----->|

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

Advantages & Disadvantages of Synchronous / Asynchronous Communications?

  Asynchronous Communication Advantages: Requests need not be targeted to specific server. Service need not be available when request is made. No blocking, so resources could be freed.  Could use connectionless protocol Disadvantages: Response times are unpredictable. Error handling usually more complex.  Usually requires connection-oriented protocol.  Harder to design apps Synchronous Communication Advantages: Easy to program Outcome is known immediately  Error recovery easier (usually)  Better real-time response (usually) Disadvantages: Service must be up and ready. Requestor blocks, held resources are “tied up”.  Usually requires connection-oriented protocol