Friday, June 5, 2009

JSTL

What is JSTL?

The JavaServer Pages Standard Tag Library (JSTL) encapsulates, as simple tags, core functionality common to many JSP applications. For example, instead of suggesting that you iterate over lists using a scriptlet or different iteration tags from numerous vendors, JSTL defines a standard tag that works the same everywhere.

You can also download JSTL taglib library from Jakarta apache project online website on http://jakarta.apache.org/builds/jakarta-taglibs/releases/standard/binaries/. Some included jar for JSTL 1.1 library are jaxen-full.jar, jstl.jar, saxpath.jar, standard.jar, xalan.jar. However, only jstl.jar and standard.jar are required.


How to Install JSTL:
1. Download jstl.jar and standard.jar
2. Put those two jar files into /common/lib/ in your Tomcat directory
(All the application under Tomcat will share those jar files inside common/lib/)
3. Below is how your code will looks like if you want to make use of JSTL in your JSP file:





Other taglib that will be used in creating dynamic webpage

We are going to download struts-taglib.jar file. Here is the website where we can find most of the jar files: http://www.java2s.com/Code/Jar/CatalogJar.htm

1. Download the strits-taglib.jar file from that website.
2. Extract the jar file
3. After the jar file has been extracted, you will fid two folders, such as: META-INF and org.
We only care about the META-INF. Open the META-INF and you will find the 'tld' folder.
The files inside the 'tld' folder: struts-bean.tld, struts-html.tld, struts-logic.tld and struts-
nested.tld

Now we will look at the struts-bean.tld.

First, create new folder 'tlib' in your WEB-INF/ directory of your Struts Application. Mine is located here C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\struts2tutorial\WEB-INF\tlib
Copy the struts-bean.tld into tlib folder.

You will need to add struts-taglib.jar file into the /common/lib/ directory of your Tomcat and use your Eclipse - Porject properties to add struts-taglib.jar.



2.

Thursday, June 4, 2009

Configuring the STRUTS application in Eclipse Version 3.4.2

Configuring the STRUTS application in Eclipse Version 3.4.2
1. Open new Java Project
2. Choose 'Create project from existing source' option. Click 'Browse' button.
3. Now, find your Struts appplication folder. (My Struts application location is C:/Program Files/Apache Software Foundation/Tomcat 5.5/webapps/struts2tutorial/ ). Click OK.
4. Name your Project. Click 'Next'.
5. Click 'Finish' and your Struts application will be added to your Eclipse.
6. Now, we will build your Struts Application by using Ant Build.
7. From your Eclipse Package Explorer, select WEB-INF --> src. Right click the 'build.xml' and click 'Ant Build'.
8. Console tab will be displayed to show the progress of the application building.
9. If you encounter failure in building the application, such as you get error message 'build.xml:55: Error starting modern compiler', it means that you are using incorrect version of JRE.
10. To resolve issue in point. 9, make sure you install higher version of JRE. In my case, I will upgrade it from JRE 1.5 to JRE 1.6
11. After you have get your JRE 1.6, you need to installed in your Eclipse. To do this, read the point 12.
12. Go to 'Run' --> 'External Tools' --> 'External Tools Configurations' --> Open the 'JRE' tab.
- Choose the 'Seperate JRE' option and click 'Installed JREs' button.
- In the next screen, choose 'Standard VM' and click 'Next'
- Click 'Directory' button next to 'JRE Home' and select the root folder of your new JRE (1.6)
- Click 'Finish' and your JRE 1.6 will be added into Installed JREs list. Make sure you tick
the checkbox next to the JRE 1.6. Click 'Ok'.
- In the 'Seperate JRE' check box, make sure you select JRE 1.6. Click 'Apply'. Click 'Run'.
- You will see that your Struts will be built successfully.
Good Luck.. ^^

Followers