[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

can't run jstl in jsp

Posted on 2004-10-27
44
Medium Priority
?
705 Views
Last Modified: 2013-11-24
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
0
Comment
Question by:angela_smith
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 25
  • 15
  • 3
  • +1
44 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 12420566
Do you have the following in your web.xml?


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

?    
0
 

Author Comment

by:angela_smith
ID: 12420658
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 12420683
>>I am not sure about c.tld

Should be core.tld

You should read up on the correct configuration ...
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 21

Expert Comment

by:MogalManic
ID: 12420809
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
 

Author Comment

by:angela_smith
ID: 12420896
>> 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
 
LVL 86

Expert Comment

by:CEHJ
ID: 12420979
>>Still getting the same error.

Actually that seems right. Did you recycle the container?
0
 

Author Comment

by:angela_smith
ID: 12421004
there is no tld file in the jstl.jar file.
Neither with c.tld nor core.tld
0
 

Author Comment

by:angela_smith
ID: 12421048
>>Did you recycle the container?
Yes done that
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12421120
Where did you get the taglibs from? You should have an archive called something like *standard* that contains the tld files
0
 

Author Comment

by:angela_smith
ID: 12421177
>>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
 

Author Comment

by:angela_smith
ID: 12421222
javax.servlet.ServletException: javax.servlet.jsp.tagext.TagAttributeInfo.<init>(Ljava/lang/String;ZLjava/lang/String;ZZ)V
0
 

Author Comment

by:angela_smith
ID: 12421255
java.lang.NoSuchMethodError: javax.servlet.jsp.tagext.TagAttributeInfo.<init>(Ljava/lang/String;ZLjava/lang/String;ZZ)V
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12421287
0
 

Author Comment

by:angela_smith
ID: 12421374
Same error.
I copied only jstl.jar and standard.jar in lib and redeployed.
Do i need to copy anything else also?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12421405
You should read the docs!
0
 
LVL 21

Expert Comment

by:MogalManic
ID: 12421834
Did you put the TLD's in the WEB_INF directory?
0
 

Author Comment

by:angela_smith
ID: 12422057
>>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
 
LVL 21

Expert Comment

by:MogalManic
ID: 12427211
The JARS need to be in the path AND the c.tld file needs to be in the WEB-INF directory.
0
 

Author Comment

by:angela_smith
ID: 12430213
c.tld file is in standard.jar
0
 

Author Comment

by:angela_smith
ID: 12430216
c.tld file is in standard.jar which is in WIB-INF lib directory
0
 

Author Comment

by:angela_smith
ID: 12430860
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
 

Author Comment

by:angela_smith
ID: 12430872
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 12436481
>>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
 

Author Comment

by:angela_smith
ID: 12441344
>>Do your libraries support jsp2
yes tomcat 5 support jsp2
0
 

Author Comment

by:angela_smith
ID: 12441618
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
 

Author Comment

by:angela_smith
ID: 12441811
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 12442262
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
 

Author Comment

by:angela_smith
ID: 12442297
>>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
 
LVL 86

Expert Comment

by:CEHJ
ID: 12442350
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
 

Author Comment

by:angela_smith
ID: 12442482
>> 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
 
LVL 86

Expert Comment

by:CEHJ
ID: 12442502
>>
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
 

Author Comment

by:angela_smith
ID: 12442518
>>Have you got the very latest version of Tomcat?

Yes, tried even the beta version
0
 

Author Comment

by:angela_smith
ID: 12442525
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
 

Author Comment

by:angela_smith
ID: 12442528
2nd and 3rd above are beta versions.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12442591
The only thing i can suggest is *lowering* the version until it comes out right ;-)
0
 

Author Comment

by:angela_smith
ID: 12442601
A lower version that jakarta-tomcat-5.0.28 would be tomcat 4.1.x which i think is not jsp2 compliant
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12442634
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
 

Author Comment

by:angela_smith
ID: 12442661
>>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
 
LVL 86

Expert Comment

by:CEHJ
ID: 12442673
>>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
 

Author Comment

by:angela_smith
ID: 12442714
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
 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 total points
ID: 12442734
>>Could that possibly be the problem ?

Yes it could. JBuilder often has pretty old binaries
0
 
LVL 8

Expert Comment

by:thomas908
ID: 12450493
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
 

Author Comment

by:angela_smith
ID: 12450518
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 12451191
No problem ;-)
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This video teaches viewers about errors in exception handling.
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question