• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

attribute problem in custom tag

 
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everybody......
I had tried to run the following programme of custom tag from HFSJ but it throws Exception as: "org.apache.jasper.JasperException: /result.jsp(7,0) According to the TLD or the tag file, attribute user> is mandatory for tag "

my source code in the programme and directory structure as:

1)C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\readTld\form.html

2)C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\readTld\result.jsp

3)C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\readTld\WEB-INF\tlds\test.tld

4)C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\readTld\WEB-INF\lib\jstl.jar

5)C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\readTld\WEB-INF\lib\standard.jar

6)C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\readTld\WEB-INF\classes\foo\AdviserTagHandler.class

And the source code as follows
1) form.html

<html>
<body>
<form action = "result.jsp" method="Get">
<h1> Login Page </h1>
Name:<input type="text"name="userName">
Password:<input type="password"name="userPassword">
<input type = "SUBMIT">
</form>
</body>
</html>

2) result.jsp

<html>
<body>

<%@ taglib prefix="mine" uri="randomThings" %>
Adviser Page


<mine:advice user ="${param.userName}" />
</body>
</html>

3)test.tld

<?xml version="1.0" encoding="ISO-8859-1" ?>
<taglib 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" version="2.0">
<tlib-version>1.1</tlib-version>
<uri>randomThings</uri>
<tag>
<description>random advice</description>
<name>advice</name>
<tag-class>foo.AdviserTagHandler</tag-class>
<body-content>empty</body-content>

<attribute>
<name>user></name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>

</tag>

</taglib>


4) and 5) are jar files

6) java file of AdviserTagHandler.class is like as:

package foo;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;

public class AdviserTagHandler extends SimpleTagSupport
{
private String user;

public void doTag() throws JspException,IOException
{
getJspContext().getOut().write("Hello"+user+"
");
getJspContext().getOut().write("Your advice is:"+getAdvice());
}

public void setUser(String user)
{
this.user = user;
}

String getAdvice()
{
String[] adviceString = {"That color's is not working for you","You should call in sick.","You might have to rethink that haircut."};
int random = (int)(Math.random()*adviceString.length);
return adviceString[random];
}
}


so, Please tell me what's wrong in this programme as it says:According to the TLD or the tag file, attribute user> is mandatory for tag
 
Ranch Hand
Posts: 437
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Pramod. There is an error present in test.tld. Use
 
Pramod P Deore
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes I think you are right.
Thank you Chinmaya

will you please tell me how the control is transfer from form.html to result.jsp and tag handler.
 
Chinmaya Chowdary
Ranch Hand
Posts: 437
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Pramod. When we submit the form, the control goes to the result.jsp. In result.jsp, there is taglib directive, the container sees the uri and locates the corresponding tld file by searching the predifined locations and it calls the appropriate tag handler class. At this time tag handler life cycle starts, and atlast control will return to the result.jsp and the response will sent to the client.
 
You firghten me terribly. I would like to go home now. Here, take this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic