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.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


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("movieList", movieList);
              RequestDispatcher rd = request.getRequestDispatcher("jsp/jstlJsp.jsp");
              rd.forward(request, response);
      }
}

thanks
angela_smithAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
Do you have the following in your web.xml?


   <taglib>
     <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
.....etc

?    
0
angela_smithAuthor Commented:
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-location>
    </taglib>

Still getting the same error. I am not sure about c.tld
Found it on googling.
What do i need to correct.
0
CEHJCommented:
>>I am not sure about c.tld

Should be core.tld

You should read up on the correct configuration ...
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

MogalManicCommented:
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</taglib-location>
    </taglib>
   2) Add the c.tld file from the JSTL distribution to your WEB-INF directory
0
angela_smithAuthor Commented:
>> 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
0
CEHJCommented:
>>Still getting the same error.

Actually that seems right. Did you recycle the container?
0
angela_smithAuthor Commented:
there is no tld file in the jstl.jar file.
Neither with c.tld nor core.tld
0
angela_smithAuthor Commented:
>>Did you recycle the container?
Yes done that
0
CEHJCommented:
Where did you get the taglibs from? You should have an archive called something like *standard* that contains the tld files
0
angela_smithAuthor Commented:
>>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.TagAttributeInfo.<init>(Ljava/lang/String;ZLjava/lang/String;ZZ)V
0
angela_smithAuthor Commented:
javax.servlet.ServletException: javax.servlet.jsp.tagext.TagAttributeInfo.<init>(Ljava/lang/String;ZLjava/lang/String;ZZ)V
0
angela_smithAuthor Commented:
java.lang.NoSuchMethodError: javax.servlet.jsp.tagext.TagAttributeInfo.<init>(Ljava/lang/String;ZLjava/lang/String;ZZ)V
0
CEHJCommented:
0
angela_smithAuthor Commented:
Same error.
I copied only jstl.jar and standard.jar in lib and redeployed.
Do i need to copy anything else also?
0
CEHJCommented:
You should read the docs!
0
MogalManicCommented:
Did you put the TLD's in the WEB_INF directory?
0
angela_smithAuthor Commented:
>>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)
0
MogalManicCommented:
The JARS need to be in the path AND the c.tld file needs to be in the WEB-INF directory.
0
angela_smithAuthor Commented:
c.tld file is in standard.jar
0
angela_smithAuthor Commented:
c.tld file is in standard.jar which is in WIB-INF lib directory
0
angela_smithAuthor Commented:
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?
0
angela_smithAuthor Commented:
This is what i got when i tried to execute one the inbuild JSP2.0 examples under jsp-examples

java.lang.NoSuchMethodError: javax.servlet.jsp.PageContext.getVariableResolver()Ljavax/servlet/jsp/el/VariableResolver;
0
CEHJCommented:
>>This is what i got when i tried to execute one the inbuild JSP2.0 examples under jsp-examples

Do your libraries support jsp2?
0
angela_smithAuthor Commented:
>>Do your libraries support jsp2
yes tomcat 5 support jsp2
0
angela_smithAuthor Commented:
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
0
angela_smithAuthor Commented:
This is the exact error I am getting

javax.servlet.ServletException: Error instantiating servlet class org.apache.jsp.jsp2.tagfiles.hello_jsp
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
      org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
      org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
      org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
      java.lang.Thread.run(Thread.java:536)


root cause

java.lang.VerifyError: (class: org/apache/jsp/jsp2/tagfiles/hello_jsp, method: _jspx_meth_tags_helloWorld_0 signature: (Ljavax/servlet/jsp/PageContext;)Z) Incompatible argument to function
      java.lang.Class.getDeclaredConstructors0(Native Method)
      java.lang.Class.privateGetDeclaredConstructors(Class.java:1590)
      java.lang.Class.getConstructor0(Class.java:1762)
      java.lang.Class.newInstance0(Class.java:276)
      java.lang.Class.newInstance(Class.java:259)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
      org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
      org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
      org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
      java.lang.Thread.run(Thread.java:536)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.

0
CEHJCommented:
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
0
angela_smithAuthor Commented:
>>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-examples
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
0
CEHJCommented:
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

0
angela_smithAuthor Commented:
>> 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
0
CEHJCommented:
>>
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?
0
angela_smithAuthor Commented:
>>Have you got the very latest version of Tomcat?

Yes, tried even the beta version
0
angela_smithAuthor Commented:
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.
0
angela_smithAuthor Commented:
2nd and 3rd above are beta versions.
0
CEHJCommented:
The only thing i can suggest is *lowering* the version until it comes out right ;-)
0
angela_smithAuthor Commented:
A lower version that jakarta-tomcat-5.0.28 would be tomcat 4.1.x which i think is not jsp2 compliant
0
CEHJCommented:
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
0
angela_smithAuthor Commented:
>>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
0
CEHJCommented:
>>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
0
angela_smithAuthor Commented:
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 ?
0
CEHJCommented:
>>Could that possibly be the problem ?

Yes it could. JBuilder often has pretty old binaries
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
thomas908Commented:
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.
0
angela_smithAuthor Commented:
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
0
CEHJCommented:
No problem ;-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.