Skip to main content

JSTL Tutorials Using NetBeans : Part-2

2. Why use JSTL?
Advantage of JSTL
  1. Scriptlets (Java codes within JSP) are complex and are extremely hard to be maintained. Unlike scriptlets, JSTL makes our JSP readable and maintainable.
  2. HTML programmer may find it hard to modify the JSP with the scriptlets as he or she may not have the Java programming knowledge. However, if we are using JSTL to replace our scriptlets, HTML programmer can easily understand on what’s going on in the JSP as JSTL is in the form of XML tags similar to the normal HTML tags.
  3. JSTL has been standardized and is reusable tags.
  4. The name of each tag in JSTL is self-explanatory and is easy to understand.
  5. JSTL requires less code compared to scriptlets.

Shortcomings of JSTL
  1. Scriptlets provide you with greater flexibility. As scriptlets is simply a Java codes, you can do anything that you want as you normally do with a Java programming. On the other hand, JSTL is a very specific and each tag has its own purposes.
 
JSTL Tutorial
Until now, you should have known the basic of the JSTL theoretically. Let’s move on to real JSTL practice. Start your NetBeans.
Create New Project
Let’s first us create new project for this tutorial. After Netbeans has already been started, choose File and New Project…
image001.png
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
A wizard dialog will show up, choose Web on the left panel and choose Web Application on the right panel. Then click Next to continue.
Image
In the step 2, we are required to fill in our project’s information details. Use self-explanatory name for the project name. Ok, let’s call it JstlDemo. We can keep the rest as default. Then click Finish.
 
Image
 
At this point, our web application is ready. File called index.jsp will be automatically created for us.
Preparing the Library

JSTL requires 2 jars; jstl.jar and standard.jar. These two files are not included in our default library. We need to add these libraries to our project.
On the left projects tab panel, we can see a folder named Libraries. Right click on this folder and Add Library…
Image
 
Image
 
After this one, we will see list of available libraries. Choose JSTL 1.1 and Add Library.
If you carefully look at the index.jsp, it contains the JSTL tag but it is commented.
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
--%>

You may try to uncomment it to test whether you have correctly imported the JSTL libraries.

Comments

  1. Java may be the main choice for enterprise development now, but it’s days are numbered as the only stalwart option to go with.

    Let’s face it, many of these so called “enterprise applications” could easily have been written much faster and with less overhead using technologies like Python, PHP, et al.






    open source training

    ReplyDelete

Post a Comment

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