3

I am new to jsp web development and debugging my application to be able to read off a database gives the following error:

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

I researched the internet on multiple sites regarding this issue for so long, unable to fix anything. These are my specs:

IDE: eclipse/ JSP version: 2.0/ Servlet version: 2.4/ JSTL version: 1.1.1/ Tomcat version: 7.0.35/

This is my WEB-INF/web.xml file

<?xml version="1.0" encoding="UTF-8" ?>
  <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
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">  
  <resource-ref>
    <description>Resource configuration for database connection</description>
    <res-ref-name>jdbc/TestDB</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>
 </web-app>

This is my META-INF/context.xml file

<?xml version="1.0" encoding="UTF-8" ?>
<Context>
<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"
           maxActive="100" maxIdle="30" maxWait="10000"
           username="admin" password="admin" driverClassName="com.mysql.jdbc.Driver"
           url="jdbc:mysql://localhost:3306/checklist_pdnf"/>

 </Context>

And this is my jsp file

<?xml version="1.0" encoding="UTF-8" ?>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

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

<sql:query var="db" dataSource="jdbs/TestDB">
select * from patient
</sql:query>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>    
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    </head>
<body>  
<div>
         <table>
    <c:forEach var="row" items="${db.rows}">    
            <tr>
            <td>row.getString("patient_medicalRecordNumber")</td>
            <td>row.getString("patient_lastName")</td>
            <td>row.getString("patient_firstName")</td>
            <td>row.getString("patient_middleName")</td>
            <td>row.getString("patient_dateOfBirth")</td>
            <td>row.getString("patient_gender")</td>
            <td>row.getString("patient_admissionDateTime")</td>
            <td>row.getString("patient_dischargeDateTime")</td>
            <td>row.getString("patient_attendingPhysician")</td>
            <td>row.getString("patient_locationRoom")</td>
        </tr>
    </c:forEach>    
     </table>
   </div> 
 </body>
</html>
naddnan
  • 161
  • 1
  • 3
  • 16
  • Check this post http://stackoverflow.com/questions/4928271/jstl-1-2-the-absolute-uri-http-java-sun-com-jstl-core-cannot-be-resolved – Rohit Feb 15 '13 at 20:35
  • I'm not sure where to add pom.xml. I have been learning as per this [link](http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html#MySQL_DBCP_Example). I tried everything on the post, but to no avail. – naddnan Feb 15 '13 at 21:02

2 Answers2

4

Turns out my JSP version was in fact 2.2, I remember opening up an about page in Eclipse to be able to get this information, but was not able to re find it for answering purposes. However, I will update this answer accordingly if necessary.

Libraries used:

(1) javax.servlet.jsp.jstl-1.2.1.jar

(2) javax.servlet.jsp.jstl-api-1.2.1.jar

(3) javax.servlet-api-3.0.1.jar

(4) mysql-connector-java-5.1.23-bin.jar

pom.xml referenced from http://java.net/projects/jsp/sources/svn/content/trunk/impl/pom.xml?rev=1440

The versions of the dependencies are:

a) javax.servlet-api 3.1. (b) javax.el-api 2.2.1. (c) javax.servlet.jsp-api 1.2.1 (d) javax.servlet.jsp.jstl-api 1.2.1. (e) jstl 1.2. (f) jstl-imp 1.2.

Reference in web.xml:

`<web-app  
  xmlns="http://java.sun.com/xml/ns/javaee" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
  http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> `
naddnan
  • 161
  • 1
  • 3
  • 16
0

As per that link, did you follow the below instruction ?

That JSP page makes use of JSTL's SQL and Core taglibs. You can get it from Apache Tomcat Taglibs - Standard Tag Library project — just make sure you get a 1.1.x or later release. Once you have JSTL, copy jstl.jar and standard.jar to your web app's WEB-INF/lib directory.

stack user1
  • 116
  • 1
  • 10
  • Yes. Here are my specifications: IDE: eclipse JSP version: 2.0 Servlet version: 2.4 JSTL version: 1.1.1 Tomcat version: 7.0.35 – naddnan Feb 19 '13 at 15:48
  • I have added both the libraries. I'm just not sure whether it's a version issue or not with Tomcat. – naddnan Feb 19 '13 at 15:50
  • Not sure what can be cause of it as if you extract these jars you will see the tlds present in them. Another approach would be explicitly adding those tlds in WEB-INF/tlds folder and refer them in web.xml, you may refer this [http://www.roseindia.net/jstl/downloading-jstl.shtml] – stack user1 Feb 20 '13 at 18:51
  • Turns out it's an issue with the jsp version and reference of associated servlet versions, etc. Thanks so much for your help everyone. I'll add the answer soon. – naddnan Feb 25 '13 at 22:59