Difference between core and core_rt jstl tag
Asked Answered
G

3

7

When I use <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> for my struts 1.3.10 project, it throws following exception:

org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:56)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:445)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:117)
    org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:311)
    org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:152)
    org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:410)
    org.apache.jasper.compiler.Parser.parseDirective(Parser.java:475)
    org.apache.jasper.compiler.Parser.parseElements(Parser.java:1427)
    org.apache.jasper.compiler.Parser.parse(Parser.java:138)
    org.apache.jasper.compiler.ParserController.doParse(ParserController.java:242)
    org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1083)
    org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:295)
    org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:396)
    org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:347)
    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:232)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

Then when I have changed it to

<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>

it works fine. I like to know what is the difference between these two and why its throws exception when I try to use <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>. Btw I using server apache-tomcat-7.0.42. Please help me.

Glob answered 22/9, 2013 at 13:8 Comment(0)
F
4

Unless you are using a very old version of JSP (JSP 1.2 or 1.1 to be exact) you shouldn't be using either of those. Those are JSTL 1.0 URIs and are not suited to modern versions of JSP.

The two libraries differed in that one would allow run-time expressions as tag attribute values, and one wouldn't. In modern JSP and JSTL, where the JSP engine does all expression evaluation, it's no longer relevant.

Fucus answered 22/9, 2013 at 13:25 Comment(3)
@vhisal-kukreja, how to know the version of jsp in netbean?Glob
@gjman2, Create simple JSP page and put following code : JSP Version : <%= JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion()%>Fucus
my jsp is 2.2, now doing wat?Glob
A
1

In JSTL 1.0, there are two versions of every template library:

  • one that doesn't allow expressions (e.g. http://java.sun.com/jstl/core)
  • one that does allow expressions (e.g. http://java.sun.com/jstl/core_rt);
Didn't allow expressions Did allow expressions
c.tld c-rt.tld
fmt.tld fmt-rt.tld
x.tld x-rt.tld
sql.tld sql-rt.tld

With JSTL 1.1, there is no longer this dichotomy.

Actinomycin answered 22/7, 2022 at 17:53 Comment(0)
T
0

I think you get the exception because the URI is different for the _rt version (_rt appended), so your taglib import is wrong for the tags in the jar you are using.

The difference is that one kind allows expression language ${someExpr} and the term relies on scriptlets <%= some code %>. You should be able to find proper details with a Google.

Tufted answered 22/9, 2013 at 13:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.