Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Custom jsp tag does not compile

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Custom jsp tag does not compile

    I get compilation errors when I try to compile the custom tag below.

    address.tag

    <%-- 
        Document   : address
        Created on : Feb 21, 2012, 1:47:19 PM
        Author     : skiabox
    --%>
     
    <%@tag description="Address Input Field" pageEncoding="UTF-8"%>
    <jsp:useBean id="addressBean" scope="session" class="com.ensode.netbeansbook.AddressBean" />
     
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
     
    <%-- The list of normal or fragment attributes can be specified here: --%>
    <%@attribute name="addressType" required="true"%>
     
    <%-- any content can be specified here e.g.: --%>
    <table border="0">
     
     
            <tr>
                <td>Line 1:&nbsp;</td>
                <td>
                    <input type="text" size="20" name="${addressType}_line1" id="${addressType}_line1" value="${addressBean.line1}" />
                </td>
            </tr>
     
            <tr>
                <td>Line 2:&nbsp;</td>
                <td>
                    <input type="text" size="20" name="${addressType}_line2" id="${addressType}_line2" value="${addressBean.line2}" />
                </td>
            </tr>
     
            <tr>
                <td>City:&nbsp;</td>
                <td>
                    <input type="text" size="20" name="${addressType}_city" id="${addressType}_city" value="${addressBean.city}" />
                </td>
            </tr>
     
            <tr>
     
                <td>State:&nbsp;</td>
                <td>
                    <select name="${addressType}_state" id="${addressType}_state">
     
                        <option value=""></option>
                        <option value="AL"
                            <c:if test="${addressBean.state == 'AL'}">selected</c:if> >
                            Alabama
                        </option>
                        <option value="AK"
                            <c:if test="${addressBean.state == 'AK'}">selected</c:if> >
                            Alaska
                        </option>
                        <option value="AZ"
                            <c:if test="${addressBean.state == 'AZ'}">selected</c:if> >
                            Arizona
                        </option>
                        <option value="AR"
                            <c:if test="${addressBean.state == 'AR'}">selected</c:if> >
                            Arkansas
                        </option>
                        <option value="CA"
                            <c:if test="${addressBean.state == 'CA'}">selected</c:if> >
                            California
                        </option>
     
                    </select>
                </td>
            </tr>
     
            <tr>
                <td>Zip:&nbsp;</td>
                <td>
                    <input type="text" name="${addressType}_zip" id="${addressType}_zip" value="${addressBean.zip}" />
                </td>
            </tr>
     
    </table>

    index6.jsp

    <%-- 
        Document   : index6
        Created on : Feb 21, 2012, 3:25:43 PM
        Author     : skiabox
    --%>
     
     
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE html>
     
    <%@taglib prefix="ct" tagdir="/WEB-INF/tags/" %>
    <%@page import="com.ensode.netbeansbook.AddressBean" %>
     
    <%
        AddressBean addressBean = new AddressBean();
        addressBean.setAddressType("home");
        addressBean.setLine1("123 Tennis Ct");
        addressBean.setCity("Phoenix");
        addressBean.setState("AZ");
        addressBean.setZip("85001");
     
        session.setAttribute("addressBean", addressBean);
    %>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
            <form>
                <ct:address addressType="home"/>
                <table cellpadding="0" cellspacing="0" border="0">
                    <tr>
                        <td style="width: 65px;"></td>
                        <td>
                            <input type="submit" value="Submit" />
                        </td>
                    </tr>
                </table>
            </form>
        </body>
    </html>


    AddressBean.java

    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package com.ensode.netbeansbook;
     
    /**
     *
     * @author skiabox
     */
    public class AddressBean {
     
        private String addressType;
        private String line1;
        private String line2;
        private String city;
        private String state;
        private String zip;
     
        public String getAddressType() {
            return addressType;
        }
     
        public void setAddressType(String addressType) {
            this.addressType = addressType;
        }
     
        public String getCity() {
            return city;
        }
     
        public void setCity(String city) {
            this.city = city;
        }
     
        public String getLine1() {
            return line1;
        }
     
        public void setLine1(String line1) {
            this.line1 = line1;
        }
     
        public String getLine2() {
            return line2;
        }
     
        public void setLine2(String line2) {
            this.line2 = line2;
        }
     
        public String getState() {
            return state;
        }
     
        public void setState(String state) {
            this.state = state;
        }
     
        public String getZip() {
            return zip;
        }
     
        public void setZip(String zip) {
            this.zip = zip;
        }
    }


    Here is the error log from netbeans :

    org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP
     
    PWC6197: An error occurred at line: 48 in the jsp file: /WEB-INF/tags/address.tag PWC6199: Generated servlet error: string:///address_tag.java:215: cannot access javax.servlet.jsp.jstl.core.ConditionalTagSupport class file for javax.servlet.jsp.jstl.core.ConditionalTagSupport not found
     
    PWC6197: An error occurred at line: 48 in the jsp file: /WEB-INF/tags/address.tag PWC6199: Generated servlet error: string:///address_tag.java:216: cannot find symbol symbol : method setPageContext(javax.servlet.jsp.PageContext) location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6197: An error occurred at line: 48 in the jsp file: /WEB-INF/tags/address.tag PWC6199: Generated servlet error: string:///address_tag.java:217: cannot find symbol symbol : method setParent() location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6197: An error occurred at line: 48 in the jsp file: /WEB-INF/tags/address.tag PWC6199: Generated servlet error: string:///address_tag.java:219: cannot find symbol symbol : method doStartTag() location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6199: Generated servlet error: string:///address_tag.java:223: cannot find symbol symbol : method doAfterBody() location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6199: Generated servlet error: string:///address_tag.java:228: cannot find symbol symbol : method doEndTag() location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6199: Generated servlet error: string:///address_tag.java:229: reuse(javax.servlet.jsp.tagext.Tag) in org.apache.jasper.runtime.TagHandlerPool cannot be applied to (org.apache.taglibs.standard.tag.rt.core.IfTag)
     
    PWC6199: Generated servlet error: string:///address_tag.java:232: reuse(javax.servlet.jsp.tagext.Tag) in org.apache.jasper.runtime.TagHandlerPool cannot be applied to (org.apache.taglibs.standard.tag.rt.core.IfTag)
     
    PWC6197: An error occurred at line: 52 in the jsp file: /WEB-INF/tags/address.tag PWC6199: Generated servlet error: string:///address_tag.java:241: cannot find symbol symbol : method setPageContext(javax.servlet.jsp.PageContext) location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6197: An error occurred at line: 52 in the jsp file: /WEB-INF/tags/address.tag PWC6199: Generated servlet error: string:///address_tag.java:242: cannot find symbol symbol : method setParent() location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6197: An error occurred at line: 52 in the jsp file: /WEB-INF/tags/address.tag PWC6199: Generated servlet error: string:///address_tag.java:244: cannot find symbol symbol : method doStartTag() location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6199: Generated servlet error: string:///address_tag.java:248: cannot find symbol symbol : method doAfterBody() location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6199: Generated servlet error: string:///address_tag.java:253: cannot find symbol symbol : method doEndTag() location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6199: Generated servlet error: string:///address_tag.java:254: reuse(javax.servlet.jsp.tagext.Tag) in org.apache.jasper.runtime.TagHandlerPool cannot be applied to (org.apache.taglibs.standard.tag.rt.core.IfTag)
     
    PWC6199: Generated servlet error: string:///address_tag.java:257: reuse(javax.servlet.jsp.tagext.Tag) in org.apache.jasper.runtime.TagHandlerPool cannot be applied to (org.apache.taglibs.standard.tag.rt.core.IfTag)
     
    PWC6197: An error occurred at line: 56 in the jsp file: /WEB-INF/tags/address.tag PWC6199: Generated servlet error: string:///address_tag.java:266: cannot find symbol symbol : method setPageContext(javax.servlet.jsp.PageContext) location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6197: An error occurred at line: 56 in the jsp file: /WEB-INF/tags/address.tag PWC6199: Generated servlet error: string:///address_tag.java:267: cannot find symbol symbol : method setParent() location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6197: An error occurred at line: 56 in the jsp file: /WEB-INF/tags/address.tag PWC6199: Generated servlet error: string:///address_tag.java:269: cannot find symbol symbol : method doStartTag() location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6199: Generated servlet error: string:///address_tag.java:273: cannot find symbol symbol : method doAfterBody() location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6199: Generated servlet error: string:///address_tag.java:278: cannot find symbol symbol : method doEndTag() location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6199: Generated servlet error: string:///address_tag.java:279: reuse(javax.servlet.jsp.tagext.Tag) in org.apache.jasper.runtime.TagHandlerPool cannot be applied to (org.apache.taglibs.standard.tag.rt.core.IfTag)
     
    PWC6199: Generated servlet error: string:///address_tag.java:282: reuse(javax.servlet.jsp.tagext.Tag) in org.apache.jasper.runtime.TagHandlerPool cannot be applied to (org.apache.taglibs.standard.tag.rt.core.IfTag)
     
    PWC6197: An error occurred at line: 60 in the jsp file: /WEB-INF/tags/address.tag PWC6199: Generated servlet error: string:///address_tag.java:291: cannot find symbol symbol : method setPageContext(javax.servlet.jsp.PageContext) location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6197: An error occurred at line: 60 in the jsp file: /WEB-INF/tags/address.tag PWC6199: Generated servlet error: string:///address_tag.java:292: cannot find symbol symbol : method setParent() location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6197: An error occurred at line: 60 in the jsp file: /WEB-INF/tags/address.tag PWC6199: Generated servlet error: string:///address_tag.java:294: cannot find symbol symbol : method doStartTag() location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6199: Generated servlet error: string:///address_tag.java:298: cannot find symbol symbol : method doAfterBody() location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6199: Generated servlet error: string:///address_tag.java:303: cannot find symbol symbol : method doEndTag() location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6199: Generated servlet error: string:///address_tag.java:304: reuse(javax.servlet.jsp.tagext.Tag) in org.apache.jasper.runtime.TagHandlerPool cannot be applied to (org.apache.taglibs.standard.tag.rt.core.IfTag)
     
    PWC6199: Generated servlet error: string:///address_tag.java:307: reuse(javax.servlet.jsp.tagext.Tag) in org.apache.jasper.runtime.TagHandlerPool cannot be applied to (org.apache.taglibs.standard.tag.rt.core.IfTag)
     
    PWC6197: An error occurred at line: 64 in the jsp file: /WEB-INF/tags/address.tag PWC6199: Generated servlet error: string:///address_tag.java:316: cannot find symbol symbol : method setPageContext(javax.servlet.jsp.PageContext) location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6197: An error occurred at line: 64 in the jsp file: /WEB-INF/tags/address.tag PWC6199: Generated servlet error: string:///address_tag.java:317: cannot find symbol symbol : method setParent() location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6197: An error occurred at line: 64 in the jsp file: /WEB-INF/tags/address.tag PWC6199: Generated servlet error: string:///address_tag.java:319: cannot find symbol symbol : method doStartTag() location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6199: Generated servlet error: string:///address_tag.java:323: cannot find symbol symbol : method doAfterBody() location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6199: Generated servlet error: string:///address_tag.java:328: cannot find symbol symbol : method doEndTag() location: class org.apache.taglibs.standard.tag.rt.core.IfTag
     
    PWC6199: Generated servlet error: string:///address_tag.java:329: reuse(javax.servlet.jsp.tagext.Tag) in org.apache.jasper.runtime.TagHandlerPool cannot be applied to (org.apache.taglibs.standard.tag.rt.core.IfTag)
     
    PWC6199: Generated servlet error: string:///address_tag.java:332: reuse(javax.servlet.jsp.tagext.Tag) in org.apache.jasper.runtime.TagHandlerPool cannot be applied to (org.apache.taglibs.standard.tag.rt.core.IfTag)
     
    /Users/skiabox/NetBeansProjects/simplewebapp2/nbproject/build-impl.xml:612: Java returned: 1 BUILD FAILED (total time: 2 seconds)


    Any ideas on what is wrong here?
    Thank you.


  2. #2
    Member
    Join Date
    Feb 2012
    Posts
    58
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default Re: Custom jsp tag does not compile

    Did you import JSTL's JAR files to project's classpath in order to compile?

Similar Threads

  1. Custom GUI in j2me
    By thiruv in forum Java ME (Mobile Edition)
    Replies: 1
    Last Post: December 15th, 2011, 08:38 AM
  2. Custom JList
    By daghost in forum AWT / Java Swing
    Replies: 3
    Last Post: November 17th, 2011, 05:57 PM
  3. Custom Log level help
    By seanman in forum Java SE APIs
    Replies: 1
    Last Post: September 25th, 2011, 08:55 PM
  4. can i use custom buttons ?
    By Gaurav18 in forum Member Introductions
    Replies: 3
    Last Post: September 12th, 2011, 09:56 AM
  5. My Custom Layout (VERY EASY TO USE)
    By aussiemcgr in forum AWT / Java Swing
    Replies: 10
    Last Post: August 5th, 2010, 01:37 PM

Tags for this Thread