Use eclipse3 + lomboz3 + Tomcat to develop JSP -- 3. A jstl instance

Source: Internet
Author: User
Tags tld
This article Article This article describes how to use lomboz to develop jstl and El. It is best to first refer to my previous article "using eclipse3.0.1 + lomboz3.0.1 + atat5.0.28 to develop jsp". The environment configuration is similar to it.

1. Required Software Jstl 1.1.1 Home http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html download http://www.apache.org/dist/jakarta/taglibs/standard/binaries/jakarta-taglibs-standard-1.1.1.zip XML buddy Home http://xmlbuddy.com download this is an Eclipse plug-in that can help edit XML files (optional ). Install the plug-in. Refer to eclipse basics-install the Eclipse plug-in using links 2. Environment Configuration Create a lomboz J2EE project with the Project name: "jstl sample"; fill in web modules: "demoweb2"; add servers: "Tomcat 5.0.28 ", as my previous article introduces eclipse new project in more detail, here is a simple introduction. Directory structure F:/j2sdk JDK directory

D:/eclipse directory F:/Java/Jakarta-Tomcat 5.0.28 Directory D:/plug-in/lomboz.301 lomboz directory (I installed it in links mode here, D: /Java/jstl jakarta-taglibs-standard-1.1.1.zip extract Directory D:/Eclipse/workspace/jstl sample just created jstl sample project directory Make appropriate Configurations Based on the installed software. 3. Add the warehouse receiving File Find the jslt/lib directory and copy the jstl. jar, standard. JAR file to the lib directory (here "D:/Eclipse/workspace/jstl sample/demoweb2/WEB-INF/lib") in the just-created "jstl sample" project directory "). Find the jstl/TLD directory and copy the c. TLD file to the/demoweb2/WEB-INF directory in the jstl sample directory. Refresh the demoweb2 directory and expand it. The added three files are displayed: 4. ModifyProgram

Note:

Since lomboz only supports jstl1.1 and later versions, El is formally incorporated into the specification in JSP 2.0. Therefore, Web. xml should use a schema of 2.4 instead of a DTD of 2.3.

Open the Web. xml file under the WEB-INF directory and modify it as follows:

WEB-INF/web. XML

 
      
xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi: schemalocation = "http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
Version = "2.4">
index. JSP

404
/error. JSP

Note:

If you have installed the xmlbuddy plug-in and use it to open "Web. XML file, the following error may occur: "cannot find the declaration of the element 'web-app'", disable "Web. XML file, the error disappears. It does not affect the running of the program.

Modify the index. jsp file

Demoweb2/index. jsp

<% @ Page contenttype = "text/html; charset = GBK" %>
<% @ Taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "C" %> <HTML>
<Head>
<Title> count to 10 example (using jstl and scriptlet) </title>
</Head>
<Body>

<% -- This is to use jstl to print 1 to 10 -- %>
Use jstl to print 1 to 10 <p>
<C: foreach Var = "I" begin = "1" End = "10" step = "1">
<C: Out value = "$ {I}"/>
<Br/>
</C: foreach>

<% -- This is the use of JSP scriptlet to print 1 to 10 -- %>
<P> use JSP scriptlet to print 1 to 10 <p>
<% For (INT I = 1; I <= 10; I ++) {%>
<% = I %> <br/>
<% }%>

</Body>
</Html>

Note:
In lomboz, only jstl 1.1 is supported. Therefore, the URI of its core tag library is http://java.sun.com/jsp/jstl/coreby default. Jstl 1.1 supports both jstl 1.0 and 1.1. Therefore, if the URI of the core tag library is http://java.sun.com/jstl/core, the core tag library of jstl 1.0 will be used, and lomboz will have an error.
5. Run the program Save the file, deploy the demoweb2 module, run the server, and enter the address: http: // localhost: 8080/demoweb2 OK in the browser window! You can see the following interface:

Next article:

Use eclipse3 + lomboz3 + Tomcat to develop JSP -- 4. a servlet instance

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.