Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with JSP using taglib uri  RSS feed

 
rakhee vissa
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using a CartServlet for the cart application in my webapps.In Product description page,there is a ADD TO CART button.Once, I hit it, CartServlet forwards the data to a JSP page called, orderform.jsp. Part of this JSP is as follows:

<%@ taglib uri="../ebook/WEB-INF/tlds/ebook.tld" prefix="msc" %>

<msc:cart>
<tr valign="top">
<td><p>
<form action="<%=response.encodeURL("/ebook/servlet/cart.CartServlet")%>" method="post">
<input type="hidden" name="ebookIsbn" value="<%=EbookIsbn%>">
<input type="hidden" name="function" value="update">
<input type=text size=2 name="quantity" value="<%=quantity%>">
<input type="submit" value="Update">
</form>
</td>

<td><%=EbookTitle%></td>
<td><%=EbookPrice%></td>
<td><%=total%></td>
</tr>
</msc:cart>


</table><br><br>

<form action="<%= response.encodeURL("/ebook/index.jsp")%>" method="post">
<input type ="submit" value ="Continue Shopping">
</form>

<form action="<%= response.encodeURL("/ebook/servlet/cart.UserServlet")%>" method="post">
<input type ="submit" value ="Checkout">
</form>

------------
The Tld file is:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">

<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.2</jspversion>
<shortname>msc</shortname>
<uri></uri>
<info>The tag library for ebook application</info>

<tag>
<name>cart</name>
<tagclass>tags.CartTag</tagclass>
<teiclass>tags.CartTEI</teiclass>
<bodycontent>JSP</bodycontent>
</tag>

<tag>
<name>order</name>
<tagclass>tags.OrderTag</tagclass>
<teiclass>tags.OrderTEI</teiclass>
<bodycontent>JSP</bodycontent>
</tag>

</taglib>
------------
Part of the CartTag.java is as follows:

private static NumberFormat currency = NumberFormat.getCurrencyInstance();

public int doStartTag(){
Cart cart = (Cart)(pageContext.findAttribute("cart"));
lineItems = cart.getItems();
if (lineItems.size()<=0){
return SKIP_BODY;
}
else{
return EVAL_BODY_BUFFERED;
}
}

public void doInitBody() throws JspException{
iterator = lineItems.iterator();
if (iterator.hasNext()){
item = (LineItem)iterator.next();
Ebook currentEbook = item.getEbook();

pageContext.setAttribute("EbookIsbn", currentEbook.getIsbn());
pageContext.setAttribute("EbookTitle", currentEbook.getTitle());

double currentPrice = currentEbook.getPrice();
String price = currency.format(currentPrice);
pageContext.setAttribute("EbookPrice", price);

Integer iQuant = new Integer(item.getQuantity());
pageContext.setAttribute("quantity", iQuant.toString());

String total = currency.format(item.getTotalPrice());
pageContext.setAttribute("total", total);
}
}

public int doAfterBody() throws JspException{
try{
if (!iterator.hasNext()){
JspWriter out = bodyContent.getEnclosingWriter();
bodyContent.writeOut(out);
return SKIP_BODY;
}
else{ //more data
item = (LineItem)iterator.next();
Ebook currentEbook = item.getEbook();
pageContext.setAttribute("EbookIsbn", currentEbook.getIsbn());
pageContext.setAttribute("ebookTitle", currentEbook.getTitle());
double currentPrice = currentEbook.getPrice();
String price = currency.format(currentPrice);
pageContext.setAttribute("ebookPrice", price);
pageContext.setAttribute("quantity", new Integer(item.getQuantity()));
String total = currency.format(item.getTotalPrice());
pageContext.setAttribute("total", total);
return EVAL_BODY_AGAIN;
}
}
catch(IOException ioe){
System.err.println("error in doAfterBody " + ioe.getMessage());
return SKIP_BODY;
}
}

}
------
It displays the following error:
*************************************
HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: javax.servlet.jsp.tagext.TagInfo.<init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljavax/servlet/jsp/tagext/TagLibraryInfo;Ljavax/servlet/jsp/tagext/TagExtraInfo;[Ljavax/servlet/jsp/tagext/TagAttributeInfo;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljavax/servlet/jsp/tagext/TagVariableInfo;Z)V
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:272)
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
cart.CartServlet.doPost(CartServlet.java:88)
javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

root cause

java.lang.NoSuchMethodError: javax.servlet.jsp.tagext.TagInfo.<init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljavax/servlet/jsp/tagext/TagLibraryInfo;Ljavax/servlet/jsp/tagext/TagExtraInfo;[Ljavax/servlet/jsp/tagext/TagAttributeInfo;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljavax/servlet/jsp/tagext/TagVariableInfo;Z)V
org.apache.jasper.compiler.TagLibraryInfoImpl.createTagInfo(TagLibraryInfoImpl.java:435)
org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:248)
org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:162)
org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:423)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:492)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1552)
org.apache.jasper.compiler.Parser.parse(Parser.java:126)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:155)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
cart.CartServlet.doPost(CartServlet.java:88)
javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.
**********************************
Could somebody help me with fixing this error?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you check Tomcat's log ?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rakhee vissa,
Javaranch tip:

If you are going to post more than a line or two of your code, wrap that
code in a set of UBB Code tags.
Doing so will help to preserve your code's indenting, making it easier to read.
If it is easier to read, more people will actaully read it and you will
stand a better chance of getting help with your question.
See UseCodeTags for more
help with UBB code tags.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the JSP forum.
 
rakhee vissa
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks .
I am using Tomcat5.0 . In TOmcat's logs directory,there are some admin files,catalina files,host-manager,localhost files,manager files. Since I am new to this version, I am not getting which files to look at. Please guide me.
 
Lalit Nagalkar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try removing "../" in your uri part of taglib
also put .tld file along with web.xml

The most important thing is you havent mentioned uri in .tld file
how can container then map uri to TagHandler class
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lalit Nagalkar:
try removing "../" in your uri part of taglib


Yes. Relative addressing makes no sense with URIs

Rather than trying to address the location of the TLD file in the file system, you should be specifying the URI that is in the TLD file itself.


also put .tld file along with web.xml


There is no need for this. Anywhere within the WEB-INF hiearchy is sufficient.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!