hi ,
i am trying to develop one jsp application with tag concept on netbeans tool.
but i am getting this error "According to TLD or tagfile, Attribute uri is mandatory for tag dbquery " . i could not run my application due to this error.

In Jsp file i wrote this code

<%@taglib uri="dbqueryuri" prefix="db"%>
<db:dbquery driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/employee?" user="root" pass="mysql" query='<%=request.getParameter("sql")%>'/>

In TLD file, i got this code

<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">
  <tlib-version>1.0</tlib-version>
  <short-name>dbquery</short-name>
  <uri>/WEB-INF/dbquery</uri>

if there is any solution , please help me....

From the looks of the error, it seems that your 'dbquery' tag requires the attribute 'uri' to be specified.
From the TLD it seems like you are using the tag file approach to create your own 'dbquery' custom tag. If so check your tag file, 'WEB-INF/dbquery' (I assume), for the following line:-

<%@attribute name="uri" ..... required="true" %>

Now change value for 'required' from true to false or remove the line completely since you do not seem to use it.

P.S. : This is just a guess, I need to see the actual contents of your tag file, to suggest anything concrete.

Hello Stefen,
I tried what you said... but still i am getting some more errors like this

"cannot find a setter method for the attribute URI of the TagHandler dbquery.DBQueryTag1"

I am sending the overall coding part , so i hope u can understand what i am trying...

In DbQueryTest.html, i have

<html>
  <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
      <form action="/DBQueryTest.jsp">
          Enter Select Query <input type="text" name="sql" value="">
          <input type="submit" name="submit" value="Click to Query">
      </form>
  </body>
</html>

In DBQueryTest.jsp, i have

<%@taglib uri="dbquery" prefix="db"%>
<db:dbquery uri="dbquery" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/employee?" user="root" pass="mysql" query='<%=request.getParameter("sql")%>'/>

In web.xml, i have

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <taglib>
        <taglib-uri>dbquery</taglib-uri>
        <taglib-location>/WEB-INF/dbquery.tld</taglib-location>
    </taglib>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>DBQueryTest.html</welcome-file>
    </welcome-file-list>
    </web-app>

In DBQuery.tld, i have

<?xml version="1.0" encoding="UTF-8"?>
<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">
  <tlib-version>1.0</tlib-version>
  <short-name>dbquery</short-name>
  <uri>/WEB-INF/dbquery</uri>

  <tag>
       <name>dbquery</name>
       <tag-class>dbquery.DBQueryTag1</tag-class>
       <body-content>empty</body-content>

        <attribute>
           <name>uri</name>
           <required>false</required>
           <rtexprvalue>false</rtexprvalue>
       </attribute>

       <attribute>
           <name>driver</name>
           <required>true</required>
           <rtexprvalue>false</rtexprvalue>
       </attribute>

       <attribute>
           <name>user</name>
           <required>true</required>
           <rtexprvalue>false</rtexprvalue>
       </attribute>
       <attribute>
           <name>pass</name>
           <required>true</required>
           <rtexprvalue>false</rtexprvalue>
       </attribute>
       <attribute>
           <name>query</name>
           <required>true</required>
           <rtexprvalue>true</rtexprvalue>
       </attribute>
   </tag>
</taglib>

In DBQueryTag1.java, i have

package dbquery;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
import java.sql.*;
public class DBQueryTag1  extends TagSupport{
       String uri,driver,url,user,pass,query;

        public void setUri(String ur)
        {
            uri=ur;
        }
        public void setDriver(String d)
        {
            driver=d;
        }
        public void setUrl(String u)
        {
            url=u;
        }
        public void setUser(String u)
        {
            user=u;
        }
        public void setPass(String p)
        {
            pass=p;
        }
        public void setQuery(String q)
        {
            query=q;
        }
        public int doStartTag() throws JspException
        {
            System.out.println("doStartTag()");
            try
            {
                JspWriter out=pageContext.getOut();
                Class.forName(driver);
                Connection con=DriverManager.getConnection(url, user, pass);
                Statement stmt=con.createStatement();
                ResultSet rs=stmt.executeQuery(query);
                ResultSetMetaData meta=rs.getMetaData();
                int colCount = meta.getColumnCount();
                out.println("<html><body><table border='1'>");
                while(rs.next())
                {
                   out.println("<tr>");
                   for(int i=1;i<=colCount;i++)
                   {
                       out.println("<td>");
                       out.println(rs.getString(i));
                       out.println("</td>");
                   }
                   out.println("</tr>");
                }
                out.println("</table> </body> </html>");
                out.close();

            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            return SKIP_BODY;
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.