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

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