aspose file tools*
The moose likes JSP and the fly likes Why the class can't handle the taglib correctly? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Why the class can Watch "Why the class can New topic
Author

Why the class can't handle the taglib correctly?

Yashnoo lyo
Ranch Hand

Joined: Feb 17, 2003
Posts: 152
Hi everyone!
I have a jsp page.There have 
<%@ taglib uri="Simpletag.tld" prefix="lyo"%>
<html>
<head>
<title>hello</title>
</head>
<body>
<p>A Group Web Matrix</p><p>
<font color=red><I>
<lyo:simple/><I></font></p>
<ul>
<li><a href="simple.jsp?choice=jspbook">Java friend</a></li>
<li><a href="simple.jsp?choice=Aspbook">.NET friend</a></li>
<li><a href="simple.jsp?choice=PHPbook">CGI friend</a></li>
</ul>
I want to the web page display the infomation when a user click the ul<li>.But it doesn't do anything when I click the choice.My Java code is:
////////////////////////////Echo.java////////////////////////////////////
public class Echo extends BodyTagSupport{
public int doStartTag()throws JspException{
String choice;
JspWriter out=pageContext.getOut();
ServletRequest request=pageContext.getRequest();
choice=new String(request.getParameter("choice"));
try{
out.println("<h4>");
out.println("You should choose");
out.println("</h4>");
out.println("<h3>");
if(choice=="Jspbook")
out.print("you choice Jsp book,right?");
else if(choice=="Aspbook")
out.print("You choice Asp book?Don't you certain?");
else if(choice=="PHPbook")
out.print("You Known ,YOu should... ...");
else
out.print("sorry!there is Nothing...");
out.println("</h3>");
}catch(IOException e){
System.out.println(e.toString());
}
return SKIP_BODY;
}
}
Who can tell me why?Thank you! :roll:


When I face C# and Java I choose Java.
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
Is your custom tag getting processed? To check, view the source of the HTML page in your browser to see if the custom tag is still there or not. If it's still in the page, then the tag isn't getting processed. If it is, then the tag is getting invoked but something is wrong with your tag handler. A couple of things spring to mind - you probably don't need to subclass BodyTagSupport (TagSupport will do) and you should always use .equals() to compare two strings.
HTH
Simon
Yashnoo lyo
Ranch Hand

Joined: Feb 17, 2003
Posts: 152
Originally posted by Simon Brown:
Is your custom tag getting processed? To check, view the source of the HTML page in your browser to see if the custom tag is still there or not. If it's still in the page, then the tag isn't getting processed. If it is, then the tag is getting invoked but something is wrong with your tag handler. A couple of things spring to mind - you probably don't need to subclass BodyTagSupport (TagSupport will do) and you should always use .equals() to compare two strings.
HTH
Simon

Thank you simon!I very love your book and I buy it that you writing usually!I have professional jsp taglib and I think it is very good for my study!In this topic,I change the "==" to "jspbook".equals("string") and it works well.Thank you again!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why the class can't handle the taglib correctly?