Results 1 to 11 of 11

Thread: Jstl

  1. #1
    Join Date
    Dec 2009
    Posts
    13
    Rep Power
    0

    Default Jstl

    how JSTL can be configured with eclipse i tried out with jst and standar jar files by adding into tomcat but its not working,please let me know any changes i need to make in web.xml

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    10

    Default

    You don't need any changes in the web.xml.
    If your container doesn't have it already then add jstl.jar to your Web-Inf/lib. Otherwise don't add it at all.

  3. #3
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    366
    Rep Power
    8

    Default

    I guess there are few different approaches, here's mine:

    1. create DIR called 'jstl' in your ../WEB-INF/lib/
    and copy needed JSTL jars in it:

    MyWebProject/WebContent/WEB-INF/lib/jstl/jstl.jar
    MyWebProject/WebContent/WEB-INF/lib/jstl/standard.jar

    2.To add this jars to classpath:

    right click on your Dynamic Web Project 'MyWebProject' and choose

    Properties => Java Build path => tab Libraries =>
    button Add JARs => in Jar selection choose jars you just copied jstl.jar and standard.jar

    (You will probably need to check
    properties => Java EE Module Dependencies => JAR/module)

    2. copy your *.tld files in

    MyWebProject/WebContent/WEB-INF/tags/templates

    3. each JSP page that will use JSTL should have this:

    Java Code:
    <%@ taglib uri="/WEB-INF/tags/templates/c.tld" prefix="c" %>
    This way there is not need to add <taglib> in web.xml

    hope this will help,
    please share you final solution to the rest of forum

    good luck!

  4. #4
    Join Date
    Dec 2009
    Posts
    13
    Rep Power
    0

    Default Still Problem

    Hi
    i tried out by your suggestion FON but its not working any alternative way??????? am using eclipse+tomcat 6+jdk1.5+jakarta-taglibs-standard-1.1.2
    i have 2 webcontent folder one is under ROOT directory and another is mineproj/webcontent i tried out in both places but getting this error on tomcat console
    SEVERE: Servlet.service() for servlet jsp threw exception
    java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/TagLibraryValidator
    Last edited by prakashkadakol; 01-12-2010 at 10:01 PM.

  5. #5
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    366
    Rep Power
    8

    Default

    Is everything OK with your servlet-api.jar versions?

    Are you using same servlet-api.jar in Tomcat and in Eclipse during
    writingt your code?

    If it is, go to any of your servlets and place this code

    Java Code:
    javax.servlet.jsp.tagext.TagLibraryValidator t = new TagLibraryValidator() {
    		};
    and you should not have any
    java.lang.NoClassDefFoundError problems

  6. #6
    Join Date
    Dec 2009
    Posts
    13
    Rep Power
    0

    Default

    mine servlet and jsp programmes are working fine under eclipse
    i tried this code javax.servlet.jsp.tagext.TagLibraryValidator t = new TagLibraryValidator() {
    };

    in servlets but this throws an error java.lang.Error: Unresolved compilation problems:
    javax.servlet.jsp.tagext cannot be resolved to a type
    The type new TypeValidator(){} must implement the inherited abstract method TypeValidator.getActualValue(String, ValidationContext)
    The type new TypeValidator(){} must implement the inherited abstract method TypeValidator.getAllowedFacets()

    DB.Testamma.doGet(Testamma.java:25)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:717)

  7. #7
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    366
    Rep Power
    8

    Default

    Once again - it's servlet-api.jar problem!

    If you use serlvet-api.jar from your Tomcat 6
    it DOES NOT contain package : javax.servlet.jsp.tagext.

    There are many other *.jars that has servlet in it's name
    and contain package javax.servlet.jsp.tagext.

    Go to
    JAR Search - findJAR.com

    type in search field name of package and class you need:
    javax.servlet.jsp.tagext.TagLibraryValidator

    and find one that will do your work (like servletapi-2.3.jar ).

    I'm not very familiar with servlet specification (2.2, 2.3 ...3.0)
    and how Tomcat implements it in his servlet-api.jar
    looks like Tomcat 6.x implements servlet 2.5 spec and those
    tags that you need are not part of it - they are extensions of some kind.

    There is a catch - it can be tricky to use different servlet kinda jars
    because Tomcat may cause problems so be patient,
    this is not just
    take another *.jar and place in on your classpath situation.

    go tiger ! you can make this work !

  8. #8
    Join Date
    Dec 2009
    Posts
    13
    Rep Power
    0

    Default st

    HI
    i added jervletapi.jar which u have mentioned now below code is in servlet
    javax.servlet.jsp.tagext.TagLibraryValidator t = new TagLibraryValidator() {
    };
    but mine jsp code ie shown below even mine simple jsp pages also throws error i think now conflict between existing servletapi.jar and new added servlet-api2.3.jar
    <%@ taglib uri="/WEB-INF/tags/templates/c.tld" prefix="c" %>
    <html>
    <head>
    <title>Count to 10 Example (using JSTL)</title>
    </head>

    <body>
    <c:forEach var="i" begin="1" end="10" step="1">
    <c:out value="${i}" />

    <br />
    </c:forEach>
    </body>
    </html>


    still throwing below error on console
    SEVERE: Servlet.service() for servlet jsp threw exception
    java.lang.NoSuchMethodError: javax.servlet.jsp.tagext.TagAttributeInfo.<init>(L java/lang/String;ZLjava/lang/String;ZZLjava/lang/String;ZZLjava/lang/String;Ljava/lang/String;)V
    at org.apache.jasper.compiler.TagLibraryInfoImpl.crea teAttribute(TagLibraryInfoImpl.java:584)
    at org.apache.jasper.compiler.TagLibraryInfoImpl.crea teTagInfo(TagLibraryInfoImpl.java:397)
    at org.apache.jasper.compiler.TagLibraryInfoImpl.pars eTLD(TagLibraryInfoImpl.java:250)
    at org.apache.jasper.compiler.TagLibraryInfoImpl.<ini t>(TagLibraryInfoImpl.java:163)
    at org.apache.jasper.compiler.Parser.parseTaglibDirec tive(Parser.java:431)
    at org.apache.jasper.compiler.Parser.parseDirective(P arser.java:494)
    at org.apache.jasper.compiler.Parser.parseElements(Pa rser.java:1444)
    at org.apache.jasper.compiler.Parser.parse(Parser.jav a:138)
    Last edited by prakashkadakol; 01-13-2010 at 05:49 PM.

  9. #9
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    366
    Rep Power
    8

    Default

    I got it ! :)

    My Tomcat 6 in lib folder contains this jar:

    C:\apache-tomcat-6.0.20\lib\jsp-api.jar

    Inside of it is package:
    javax.servlet.jsp.tagext

    Maybe this jar must use some other jars that are in same lib folder
    so check out your Tomcat!

    Remove all new servlet jars that make a conflict,
    and try with this

  10. #10
    Join Date
    Dec 2009
    Posts
    13
    Rep Power
    0

    Default still a problem with JSTL

    hi

    i have made changes but nothing has been changed in error

  11. #11
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    366
    Rep Power
    8

    Default

    Have we or have we not resolve first error you posted:

    "SEVERE: Servlet.service() for servlet jsp threw exception
    java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/TagLibraryValidator"

    Now that we know that jsp-api.jar contains that class
    this should be resolved?

    After you answer question above
    please post your exact error again so we can continue ;)

Similar Threads

  1. List + JSTL
    By initmax in forum Java Servlet
    Replies: 8
    Last Post: 11-05-2009, 12:56 PM
  2. Why are we using JSTL in jsp?
    By makpandian in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 06-30-2009, 10:15 PM
  3. jstl tag <if>
    By subha in forum Advanced Java
    Replies: 1
    Last Post: 04-02-2009, 09:07 PM
  4. jstl in jsp
    By nagaprasanna in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 11-18-2008, 09:18 AM
  5. JSTL error
    By Eric in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 06-11-2007, 09:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •