开发者

What does this error means in JSP? (Unknown element (rtexpvalue) in attribute)

I am getting this error when running my application on LINE 3 of the jsp file.Is it to do with my tld file or jsp file?

org.apache.jasper.JasperException: /DisplayAllOrders.jsp(3,62) PWC6106: Unknown element (rtexpvalue) in attribute.

The TLD file:

 <?xml version="1.0" encoding="UTF-8"?>
 <taglib version="2.0" xmlns="http://java.sun.com/xml/ns/j2ee"    lns:xsi="http://www.w3.org/2001/XMLSchema-instance"      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd">
 <tlib-version>1.0</tlib-version>
 <short-name>week07_portfolio<开发者_如何学Go;/short-name>
 <uri>/WEB-INF/tlds/week07_portfolio</uri>
<tag>
<name>DisplayOrders</name>
<tag-class>tags.DisplayOrders</tag-class>
<body-content>JSP</body-content>
<variable>
    <name-given>order</name-given>
    <variable-class>beans.Order</variable-class>
    <declare>true</declare>
    <scope>NESTED</scope>
</variable>       
<attribute>
      <name>ordersListName</name>
      <required>true</required>
      <rtexpvalue>false</rtexpvalue>
</attribute>
   </tag>
   <tag>
   <name>DisplayOrderLines</name>
   <tag-class>tags.DisplayOrderLines</tag-class>
   <body-content>JSP</body-content>
<variable>
    <name-given>orderLine</name-given>
    <variable-class>beans.OrderLine</variable-class>
    <declare>true</declare>
    <scope>NESTED</scope>
</variable>     
 <attribute>
      <name>linesListName</name>
      <required>true</required>
      <rtexpvalue>false</rtexpvalue>
  </attribute>    
  </tag>
 </taglib>

the JSP file:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="java.util.*, java.text.*, beans.*" %>
<%@ taglib uri="/WEB-INF/tlds/week07_portfolio" prefix="wk07" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<%  if (session.getAttribute("orderList") == null)
{
    throw new ServletException("No order list available");
}

int ctr = 0;
SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy");

%>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Week 07, Portfolio Exercise</title>
    <link rel="stylesheet" type="text/css" href="Week07_Portfolio.css">
    </head>
    <body>
    <h1>Week 07, Portfolio Exercise</h1>
    <h2>Order list</h2>

    <wk07:DisplayOrders ordersListName="orderList">
        <table>
            <tr class="header">
                <td>Order Num: <%= order.getOrderNum() %></td>
                <td>Customer: <%= order.getName() %></td>
                <td>Date: <%= df.format(order.getOrderDate()) %></td>
            </tr>
        </table>

        <% pageContext.setAttribute("orderLines", order.getOrderLines()); 
           ctr = 0;
        %>
        <table>
            <tr>
                <th>Ref. Code</th>
                <th>Item</th>
                <th>Qty</th>
            </tr>
        <wk07:DisplayOrderLines linesListName="orderLines">
            <tr<%= ctr++ % 2 == 0 ? " class=\"shaded\"" : ""%>>
                <td><%= orderLine.getItem().getRefCode()%></td>
                <td><%= orderLine.getItem().getName()%></td>
                <td><%= orderLine.getQuantity()%></td>
            </tr>
        </wk07:DisplayOrderLines>
        </table>
        <p>&nbsp;</p>
    </wk07:DisplayOrders>        
</body>


It should be <rtexprvalue>.


Your taglib root declaration is broken.

<taglib version="2.0" 
    xmlns="http://java.sun.com/xml/ns/j2ee"
    lns:xsi="http://www.w3.org/2001/XMLSchema-instance"       
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd">

The lns must be xmlns and there must be a / between j2ee and web-jsptaglibrary_2_0.xsd.

The correct declaration is as follows:

<taglib version="2.0"
    xmlns="http://java.sun.com/xml/ns/j2ee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd">

As a side-note, ensure that the web-app root declaration of your web.xml is at least as per Servlet 2.4. Else it will still not work.

<web-app 
    xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">

Unrelated to the problem, using scriptlets in JSP is discouraged since a decade.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜