Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

A error occured on JSP custom tag...

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
I am using a custom tag - that uses a JavaScriptDate bean...i did test it separately it works fine in a Jsp page...
Now, I created a Tag class as JavaScriptDateTag.java that has the following code:
class JavaScriptDateTag extends TagSupport {
public int doStartTag() {
try {
JspWriter out = pageContext.getOut();
JavaScriptDate now = new JavaScriptDate();
out.write(now.getScriptDate());
} catch (IOException e) {
System.out.println("Error in JavaScriptDateTag" +
e.getMessage());
}
return TagSupport.SKIP_BODY;
}
}
----
I also included this tag in JavaScriptDateTag.tld file...as today. this file contains one more tag "message" :
<tag>
<name>today</name>
<tagclass>vlv.mserver.mtags.JavaScriptDate</tagclass>
<info>Display current date</info>
</tag>

<tag>
<name>message</name>
<tagclass>vlv.mserver.mtags.JavaScriptExampleTag</tagclass>
<info>Display Alert Box</info>
</tag>
-----
Now i tried in a JSP page i get an error as follows:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 5 in the jsp file: /jsps/tester.jsp
Generated servlet error:
D:\tomcat4.0.6\work\Standalone\localhost\iqc\jsps\tester$jsp.java:60: Method setPageContext(javax.servlet.jsp.PageContext) not found in class vlv.mserver.mtags.JavaScriptDate.
_jspx_th_js_today_0.setPageContext(pageContext);
^
----
The code in jsp page:
<%@ taglib uri="http://www.jsp.com/jspkit/javascript"; prefix="js" %>
<html>
<body bgcolor="#ccffff">
Hi, <br> Here follows today's date:<js:today />
<js:message>Hello</js:message>
</body>
</html>
-----
I have refered many books and couldn't get a solution to over come this ...
Anyone pl. guide me... Thanks a lot
 
Vanchi Nathan
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all
Thanks a lot , i found the error it was in the "*.tld" file, the <tagclass> tag was pointed to the Javabean instead of the Tag class. Following is the correct code in tld file:
<tag>
<name>today</name>
<tagclass>vlv.mserver.mtags.JavaScriptDateTag</tagclass>
<info>Display current date</info>
</tag>
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic