Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem With CustomTags "cannot be resolved to a type", please rectify it.  RSS feed

 
Praneeth Thiruveedhula
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
this is praneeth, iam facing problem in customtags from 24 hours continuesly,please rectify it.
Problem:
in the test.jsp iam using <durga:cstag/> iam getting unresolved type error.
iam sending the all components. please look at once.

Exact folder structure

customtagsdemo
|
|-------test.jsp
|-------WEB-INF
@@@@@@|----------web.xml
@@@@@@|----------MyTld.tld
@@@@@@|----------classes
@@@@@@@@@@@|------CustomTagDemo
@@@@@@|----------lib

test.jsp
<%@ taglib prefix="durga" uri="javamirchi" %>
<durga:cstag>
hi this is tag body
</durga:cstag>
<durga:cstag/><br>
this is after tagbody

web.xml

<web-app>
<jsp-config>
<taglib>
<taglib-uri>javamirchi</taglib-uri>
<taglib-location>/WEB-INF/MyTld.tld</taglib-location>
</taglib>
</jsp-config>
</web-app>

MyTld.tld

<taglib version="2.1">
<tlib-version>1.2.3</tlib-version>
<tag>
<name>cstag</name>
<tagclass>CustomTagDemo</tagclass>
</tag>
</taglib>

CustomTagDemo

import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
public class CustomTagDemo implements Tag
{
PageContext pcontext;
public void setPageContext(PageContext p)
{
pcontext=p;
}
public void setParent(Tag t)
{
}
public int doStartTag()throws JspException
{
try{
JspWriter out=pcontext.getOut();
out.println("hi this is taghandler class");
}
catch(IOException e){}
return EVAL_BODY_INCLUDE;
}
public int doEndTag()throws JspException
{
return EVAL_PAGE;
}
public void release()
{}
public Tag getParent()
{
return null;
}
}




So i request you please run it and rectify the problem.
Thanks,
Praneeth.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.
 
Teena George
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Praneeth,

There are some small mistakes in your code:
1. In your tld file, it should be <tag-class> instead of <tagclass>
I modified your tld file as below :


note that I added a package and then created your class. When I tried it without the package, I got an exception saying 'CustomTagDemo' can't be resolved to a type.
Its always recommended to add classes inside package.

I got the output for your code, without any other modification.
HTH,
Teena
 
Praneeth Thiruveedhula
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Teena Thanks for replying,i saw your code.its fine.finally i trace the problem, i.e iam using tomcat5.5 version.for that version we must use the jsp version 2.0 this is the major problem.

Thanks a lot for replying.
 
Teena George
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problem. I was using jboss 4.2 to test it.

Regards,
Teena
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!