aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes can't run jstl in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "can Watch "can New topic
Author

can't run jstl in jsp

Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100
I am trying to use jstl in my jsp page but its giving hte following error.



i have copied jstl.jar in my webapps lib directory.
Here is my jsp file


here is my servlet


thanks
Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100
here is my web.xml


[ October 27, 2004: Message edited by: Angela lewis ]

There is no tld file in jstl.jar
[ October 27, 2004: Message edited by: Angela lewis ]
Nitish Bahadur
Ranch Hand

Joined: Aug 25, 2003
Posts: 118
This might help http://java.about.com/library/weekly/aa_jstl_intro_2.htm
Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100
Originally posted by Nitish Bahadur:
This might help http://java.about.com/library/weekly/aa_jstl_intro_2.htm


It has mentioned anything abt changes to be made in web.xml. If i don't make any changes in web.xml still get the same error.
Surprisingly there's no mention of changes of changes in wex.xml for using jstl in HF Servlets and JSP.
Is it needed or not?
Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100
I hadn't copied standard.jar in teh lib. i did that and now i am getting the follwoing error


javax.servlet.ServletException: javax.servlet.jsp.tagext.TagAttributeInfo.<init>(Ljava/lang/String;ZLjava/lang/String;ZZ)V
Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100
java.lang.NoSuchMethodError: javax.servlet.jsp.tagext.TagAttributeInfo.<init>(Ljava/lang/String;ZLjava/lang/String;ZZ)V
Jessica White
Ranch Hand

Joined: Sep 24, 2004
Posts: 30
Angela:

I am not sure what problem is in your code.
But having both jstl.jar and standar.jar in WEB-INF\lib directory of your web app should make JSTL work.

Here is what I tried, just one JSP with scriptlet, and it works.(I did not put anything in my web.xml about JSTL)

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html><body>
<strong> Movie List: </strong>
<br><br>

<% String[] movieList={"Lion King", "Harry Potter", "Hero"};
request.setAttribute("movieList", movieList); %>

<table>
<c:forEach var="movie" items="${movieList}" >
<tr>
<td>${movie}</td>
</tr>
</c:forEach>
</table>

</body></html>

You can try this to see if it works.
Jessica White
Ranch Hand

Joined: Sep 24, 2004
Posts: 30
Angela:

It looks like you need to remove whatever you add to web.xml to declare the tld since that is not necessary. (see HFS page 475 for explanation)

Secondly, look at your html code, you mistyped closing tag to be <c:forEach> instead of </c:forEach>

--Jessica
Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100
Originally posted by Jessica White:
Angela:

It looks like you need to remove whatever you add to web.xml to declare the tld since that is not necessary. (see HFS page 475 for explanation)

Secondly, look at your html code, you mistyped closing tag to be <c:forEach> instead of </c:forEach>

--Jessica


Thanks jessica for replying.
I have corrected the <c:forEach> tag. Deleted the entry from web.xml and tried using your example but still getting this error

javax.servlet.ServletException: javax.servlet.jsp.tagext.TagAttributeInfo.<init>(Ljava/lang/String;ZLjava/lang/String;ZZ)V
Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100
I think there is some other 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 tell me what could be the problem.
Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100
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;
Nitish Bahadur
Ranch Hand

Joined: Aug 25, 2003
Posts: 118
Curiosity, what version of Tomcat are you running?
Colin Fletcher
Ranch Hand

Joined: Sep 10, 2004
Posts: 200
You will need both jstl.jar and standard.jar and need Tomcat 5.x


SCJP 1.4 SCWCD 1.4
Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100
Originally posted by Colin Fletcher:
You will need both jstl.jar and standard.jar and need Tomcat 5.x


I am using Tomcat 5.0 and I am only trying to run the inbuild examples under jsp-examples (both the jar files are available there) at this url

http://localhost:8080/jsp-examples
Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100
Originally posted by Nitish Bahadur:
Curiosity, what version of Tomcat are you running?


Only 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.
Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100
I have uninstalled and reinstalled tomcat a number of times. Even tried using the beta version jakarta-tomcat-5.0.29 but no use. Same error everywhere.
Did it on another machine also but same problem there. I wonder why no one else faced this problem.
Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100
this is the exact error i get

exception

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.
Nitish Bahadur
Ranch Hand

Joined: Aug 25, 2003
Posts: 118
What is your JAVA_HOME set to? Can you please tell us the java version Tomcat is using?
Colin Fletcher
Ranch Hand

Joined: Sep 10, 2004
Posts: 200
Angela,

I am using Tomcat 5.0.29 with JDK 1.4.2 and works for me... I agree with the last post. I would double check your Java version....
Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100
the problem was jbuilder8. There must be some old binaries which were conflicitng with new JSP2,0 binaries. I uninstalled Jbuilder is its working fine now
thanks everyone
Mili
Greenhorn

Joined: Nov 25, 2004
Posts: 1
Hi..Even I am facing the same problem...JSP 2.0 examples are not working on my system but JSP1.2 examples are.Moreover,if I use formbean in struts it gives me the same error..Can anyone help..ITS URGENT...
Ales Justin
Greenhorn

Joined: Oct 05, 2004
Posts: 4
I'm using IntelliJ IDEA and had the same problems.
I was switching project settings a lot and at one time it stopped working.
I then created new project space from scratch and it worked normally again.
Dale Seng
Ranch Hand

Joined: Mar 22, 2004
Posts: 275
If you are getting the wrong method signature exception on TagAttributeInfo
it means you have got down-level javax.servet code. You might consider
a "nuke and pave" reinstall (just get the latest from the Sun site). But
if you're like me, you have some other environment (for me it was JBoss).

I was able to find that the
TagAttributeInfo class resides in jsp-api.jar (that comes with the
JBoss install) as well as j2ee.jar, that comes with Sun's j2ee.

The solution was to jar-up only the javax.servlet classes from j2ee.jar,
and put that subset jar in the JBOSS_HOME environment variable. Works like
a charm now. Google drs.usenet and TagAttributeInfo for details.

--Dale--
[ November 26, 2004: Message edited by: Dale Seng ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can't run jstl in jsp