angela_smith
asked on
can't run jstl in jsp
I am trying to use jstl in my jsp page but its giving hte following error.
org.apache.jasper.JasperEx ception: 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 have copied jstl.jar in my webapps lib directory.
Here is my jsp file
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<body>
<table>
<c:forEach var="movie" items="${movieList}" >
<tr>
<td>${movie}</td>
</tr>
<c:forEach>
</table></body></html>
here is my servlet
package com.example.ams;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class JstlServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String[] movieList = {"Amelie", "Return of the King", "Mean Girls"};
request.setAttribute("movi eList", movieList);
RequestDispatcher rd = request.getRequestDispatch er("jsp/js tlJsp.jsp" );
rd.forward(request, response);
}
}
thanks
org.apache.jasper.JasperEx
i have copied jstl.jar in my webapps lib directory.
Here is my jsp file
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<body>
<table>
<c:forEach var="movie" items="${movieList}" >
<tr>
<td>${movie}</td>
</tr>
<c:forEach>
</table></body></html>
here is my servlet
package com.example.ams;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class JstlServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String[] movieList = {"Amelie", "Return of the King", "Mean Girls"};
request.setAttribute("movi
RequestDispatcher rd = request.getRequestDispatch
rd.forward(request, response);
}
}
thanks
ASKER
Thanks
No it wasn't there.
Now i have done this
<taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/ lib/c.tld< /taglib-lo cation>
</taglib>
Still getting the same error. I am not sure about c.tld
Found it on googling.
What do i need to correct.
No it wasn't there.
Now i have done this
<taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/
</taglib>
Still getting the same error. I am not sure about c.tld
Found it on googling.
What do i need to correct.
>>I am not sure about c.tld
Should be core.tld
You should read up on the correct configuration ...
Should be core.tld
You should read up on the correct configuration ...
For every taglib you use you need to add the following to your configureation
1) Add to the Web XML the TLD definition
E.G:
<taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
<taglib-location>c.tld</ta glib-locat ion>
</taglib>
2) Add the c.tld file from the JSTL distribution to your WEB-INF directory
1) Add to the Web XML the TLD definition
E.G:
<taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
<taglib-location>c.tld</ta
</taglib>
2) Add the c.tld file from the JSTL distribution to your WEB-INF directory
ASKER
>> Add the c.tld file from the JSTL distribution to your WEB-INF directory
I have added the whole jstl.jar to WEB-INF/lib directory
I have added the whole jstl.jar to WEB-INF/lib directory
>>Still getting the same error.
Actually that seems right. Did you recycle the container?
Actually that seems right. Did you recycle the container?
ASKER
there is no tld file in the jstl.jar file.
Neither with c.tld nor core.tld
Neither with c.tld nor core.tld
ASKER
>>Did you recycle the container?
Yes done that
Yes done that
Where did you get the taglibs from? You should have an archive called something like *standard* that contains the tld files
ASKER
>>Where did you get the taglibs from? You should have an archive called something like *standard* that contains the tld files
That seems to be problem. I copied standard.jar to the lib and nor i am getting this.
javax.servlet.jsp.tagext.T agAttribut eInfo.<ini t>(Ljava/l ang/String ;ZLjava/la ng/String; ZZ)V
That seems to be problem. I copied standard.jar to the lib and nor i am getting this.
javax.servlet.jsp.tagext.T
ASKER
javax.servlet.ServletExcep tion: javax.servlet.jsp.tagext.T agAttribut eInfo.<ini t>(Ljava/l ang/String ;ZLjava/la ng/String; ZZ)V
ASKER
java.lang.NoSuchMethodErro r: javax.servlet.jsp.tagext.T agAttribut eInfo.<ini t>(Ljava/l ang/String ;ZLjava/la ng/String; ZZ)V
I'd start again with a fresh copy:
http://www.apache.org/dist/jakarta/taglibs/standard/jakarta-taglibs-standard-current.zip
http://www.apache.org/dist/jakarta/taglibs/standard/jakarta-taglibs-standard-current.zip
ASKER
Same error.
I copied only jstl.jar and standard.jar in lib and redeployed.
Do i need to copy anything else also?
I copied only jstl.jar and standard.jar in lib and redeployed.
Do i need to copy anything else also?
You should read the docs!
Did you put the TLD's in the WEB_INF directory?
ASKER
>>Did you put the TLD's in the WEB_INF directory?
put both the jar files in WEB-INF/lib
(standard.jar and jstl.jar)
put both the jar files in WEB-INF/lib
(standard.jar and jstl.jar)
The JARS need to be in the path AND the c.tld file needs to be in the WEB-INF directory.
ASKER
c.tld file is in standard.jar
ASKER
c.tld file is in standard.jar which is in WIB-INF lib directory
ASKER
I dont know what could be the reason.
None of the build in JSP 2.0 examples under jsp-examples directory are running. But JSP 1.2 examples are running fine.
please help me, what could be the problem?
None of the build in JSP 2.0 examples under jsp-examples directory are running. But JSP 1.2 examples are running fine.
please help me, what could be the problem?
ASKER
This is what i got when i tried to execute one the inbuild JSP2.0 examples under jsp-examples
java.lang.NoSuchMethodErro r: javax.servlet.jsp.PageCont ext.getVar iableResol ver()Ljava x/servlet/ jsp/el/Var iableResol ver;
java.lang.NoSuchMethodErro
>>This is what i got when i tried to execute one the inbuild JSP2.0 examples under jsp-examples
Do your libraries support jsp2?
Do your libraries support jsp2?
ASKER
>>Do your libraries support jsp2
yes tomcat 5 support jsp2
yes tomcat 5 support jsp2
ASKER
Tomcat 5 has inbuild jstl examples under jsp-examples. Had it been an earlier version there wouldn't have been inbuild jstl examples. I tried making my own jsp pages using jstl but there is the same error as there is while executing inbuild jstl examples
ASKER
This is the exact error I am getting
javax.servlet.ServletExcep tion: Error instantiating servlet class org.apache.jsp.jsp2.tagfil es.hello_j sp
org.apache.catalina.authen ticator.Au thenticato rBase.invo ke(Authent icatorBase .java:462)
org.apache.catalina.valves .ErrorRepo rtValve.in voke(Error ReportValv e.java:118 )
org.apache.coyote.tomcat5. CoyoteAdap ter.servic e(CoyoteAd apter.java :160)
org.apache.coyote.http11.H ttp11Proce ssor.proce ss(Http11P rocessor.j ava:799)
org.apache.coyote.http11.H ttp11Proto col$Http11 Connection Handler.pr ocessConne ction(Http 11Protocol .java:705)
org.apache.tomcat.util.net .TcpWorker Thread.run It(PoolTcp Endpoint.j ava:577)
org.apache.tomcat.util.thr eads.Threa dPool$Cont rolRunnabl e.run(Thre adPool.jav a:683)
java.lang.Thread.run(Threa d.java:536 )
root cause
java.lang.VerifyError: (class: org/apache/jsp/jsp2/tagfil es/hello_j sp, method: _jspx_meth_tags_helloWorld _0 signature: (Ljavax/servlet/jsp/PageCo ntext;)Z) Incompatible argument to function
java.lang.Class.getDeclare dConstruct ors0(Nativ e Method)
java.lang.Class.privateGet DeclaredCo nstructors (Class.jav a:1590)
java.lang.Class.getConstru ctor0(Clas s.java:176 2)
java.lang.Class.newInstanc e0(Class.j ava:276)
java.lang.Class.newInstanc e(Class.ja va:259)
org.apache.catalina.authen ticator.Au thenticato rBase.invo ke(Authent icatorBase .java:462)
org.apache.catalina.valves .ErrorRepo rtValve.in voke(Error ReportValv e.java:118 )
org.apache.coyote.tomcat5. CoyoteAdap ter.servic e(CoyoteAd apter.java :160)
org.apache.coyote.http11.H ttp11Proce ssor.proce ss(Http11P rocessor.j ava:799)
org.apache.coyote.http11.H ttp11Proto col$Http11 Connection Handler.pr ocessConne ction(Http 11Protocol .java:705)
org.apache.tomcat.util.net .TcpWorker Thread.run It(PoolTcp Endpoint.j ava:577)
org.apache.tomcat.util.thr eads.Threa dPool$Cont rolRunnabl e.run(Thre adPool.jav a:683)
java.lang.Thread.run(Threa d.java:536 )
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
javax.servlet.ServletExcep
org.apache.catalina.authen
org.apache.catalina.valves
org.apache.coyote.tomcat5.
org.apache.coyote.http11.H
org.apache.coyote.http11.H
org.apache.tomcat.util.net
org.apache.tomcat.util.thr
java.lang.Thread.run(Threa
root cause
java.lang.VerifyError: (class: org/apache/jsp/jsp2/tagfil
java.lang.Class.getDeclare
java.lang.Class.privateGet
java.lang.Class.getConstru
java.lang.Class.newInstanc
java.lang.Class.newInstanc
org.apache.catalina.authen
org.apache.catalina.valves
org.apache.coyote.tomcat5.
org.apache.coyote.http11.H
org.apache.coyote.http11.H
org.apache.tomcat.util.net
org.apache.tomcat.util.thr
java.lang.Thread.run(Threa
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
That looks like some kind of binary incompatibility. Make sure all libraries are symmetrical. i.e. don't compile against different libraries than you'll be running against and make sure you have the latest versions of libraries. The safest thing to do is to compile against Tomcat's own jars
ASKER
>>The safest thing to do is to compile against Tomcat's own jars
Thats exactly what I am doing. This error comes while executing Tomcats build in examples at
http:// localhost:8080/jsp-example s
and for executing its own examples Tomcat uses its own libraries that comes with tomcat 5. i have not put in any jar file myself
Thats exactly what I am doing. This error comes while executing Tomcats build in examples at
http:// localhost:8080/jsp-example
and for executing its own examples Tomcat uses its own libraries that comes with tomcat 5. i have not put in any jar file myself
I thought earlier you'd been placing tag lib binaries in Tomcat's classpath? (That was the whole thrust of the earlier part of this question)
When you've double-checked the binaries, try deleting the compiled servlets (from the JSP) and recycle the container
When you've double-checked the binaries, try deleting the compiled servlets (from the JSP) and recycle the container
ASKER
>> thought earlier you'd been placing tag lib binaries in Tomcat's classpath? (That was the whole thrust of the earlier part of this question)
yes CEHJ u r absolutely right, that was the whole thrust of the earlier ques. But when it didn't work i tried the inbuild examples under jsp-examples to see if they work. But even they gave the same error. So, if the inbuild examples under jsp-exampels start working i guess there woudn't be much problem in making my own jsp's do the same. For inbuild examples all jar files are already in the classpath.
So when I go to this url http://localhost:8080/jsp-examples
Tomcat shows a page in which there are a lot of examples under the head JSP2.0 and JSP1.2. Every example has 2 links "execute" and "source". Clicking on source cause no problem. Clicking on execute of jsp1.2 examples causes no problem. But clicking in execute of jsp2.0 gives the above weird error. Tomcat5.0 is jsp2.0 compliant server (that's why they have those inbuild examples)
>>When you've double-checked the binaries, try deleting the compiled servlets (from the JSP) and recycle the container
I have uninstalled and reinstalled tomcat atleast 20 times. Also did on another machine (my home PC) . But same problem is everwhere.
Infact I googled a lot and saw this problem in quite a few question in various forums but none of it had any answer that solved the problem
yes CEHJ u r absolutely right, that was the whole thrust of the earlier ques. But when it didn't work i tried the inbuild examples under jsp-examples to see if they work. But even they gave the same error. So, if the inbuild examples under jsp-exampels start working i guess there woudn't be much problem in making my own jsp's do the same. For inbuild examples all jar files are already in the classpath.
So when I go to this url http://localhost:8080/jsp-examples
Tomcat shows a page in which there are a lot of examples under the head JSP2.0 and JSP1.2. Every example has 2 links "execute" and "source". Clicking on source cause no problem. Clicking on execute of jsp1.2 examples causes no problem. But clicking in execute of jsp2.0 gives the above weird error. Tomcat5.0 is jsp2.0 compliant server (that's why they have those inbuild examples)
>>When you've double-checked the binaries, try deleting the compiled servlets (from the JSP) and recycle the container
I have uninstalled and reinstalled tomcat atleast 20 times. Also did on another machine (my home PC) . But same problem is everwhere.
Infact I googled a lot and saw this problem in quite a few question in various forums but none of it had any answer that solved the problem
>>
So, if the inbuild examples under jsp-exampels start working i guess there woudn't be much problem in making my own jsp's do the same
>>
That's a sensible approach.
>>
this problem in quite a few question in various forums but none of it had any answer that solved the problem
>>
Have you got the very latest version of Tomcat?
So, if the inbuild examples under jsp-exampels start working i guess there woudn't be much problem in making my own jsp's do the same
>>
That's a sensible approach.
>>
this problem in quite a few question in various forums but none of it had any answer that solved the problem
>>
Have you got the very latest version of Tomcat?
ASKER
>>Have you got the very latest version of Tomcat?
Yes, tried even the beta version
Yes, tried even the beta version
ASKER
these are teh versions i have tried
jakarta-tomcat-5.0.28
jakarta-tomcat-5.0.29
jakarta-tomcat-5.5.3
There is no version after this.
jakarta-tomcat-5.0.28
jakarta-tomcat-5.0.29
jakarta-tomcat-5.5.3
There is no version after this.
ASKER
2nd and 3rd above are beta versions.
The only thing i can suggest is *lowering* the version until it comes out right ;-)
ASKER
A lower version that jakarta-tomcat-5.0.28 would be tomcat 4.1.x which i think is not jsp2 compliant
Yes, i thought that might happen. I can't believe, btw, that all 3 of those versions you mention are 'genuinely' defective, so you must inspect your environment *very* closely for binaries knocking around from earlier attempts. Make sure you empty everything before installing a new version, even scouring your system for stale jars. Don't think of installing over an old one
ASKER
>>Make sure you empty everything before installing a new version, even scouring your system for stale jars. Don't think of installing over an old one
I emptied everything. Never deleted but uninstalled and then even used system mechanic to clear registry entries and get rid of useless files. Installed tomcat on different drives with different name. i have done it all. The only option i can think of now is format my hard drive and makea clean install
I emptied everything. Never deleted but uninstalled and then even used system mechanic to clear registry entries and get rid of useless files. Installed tomcat on different drives with different name. i have done it all. The only option i can think of now is format my hard drive and makea clean install
>>The only option i can think of now is format my hard drive and makea clean install
That would be over-the-top i think ;-) I think there must be something you've missed. Uninstall again and then post a listing of all jars on the drive
That would be over-the-top i think ;-) I think there must be something you've missed. Uninstall again and then post a listing of all jars on the drive
ASKER
The have jbuilder8 installed in one of the drives (although I am not using jbuilder for this) and java_home is set to the jdk inside the jbuilder.
Could that possibly be the problem ?
Could that possibly be the problem ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
CEHJ is absolutely right.
Uninstall JBUilder and clear all ur classapaths. Even then the problem is not solved then delete ur existing jar files and make a fresh install for jdk and tomcat.
With jsp2 u don't even need to make any entry in web.xml, so a proper installation will do it for u.
Uninstall JBUilder and clear all ur classapaths. Even then the problem is not solved then delete ur existing jar files and make a fresh install for jdk and tomcat.
With jsp2 u don't even need to make any entry in web.xml, so a proper installation will do it for u.
ASKER
Thanks CEHJ , its working now.
I uninstalled everything. cleared all the classpaths and deleted all the jar files in my system and made a clean install. Its working now.
It was so nice of u CEHJ to work it up all along.
thanks again
I uninstalled everything. cleared all the classpaths and deleted all the jar files in my system and made a clean install. Its working now.
It was so nice of u CEHJ to work it up all along.
thanks again
No problem ;-)
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
.....etc
?