Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JSP
Search Coderanch
Advance search
Google search
Register / Login
Help coderanch get a
new server
by contributing to the
fundraiser
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
Ron McLeod
Paul Clapham
Devaka Cooray
Liutauras Vilda
Sheriffs:
Jeanne Boyarsky
paul wheaton
Henry Wong
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Tim Moores
Carey Brown
Mikalai Zaikin
Bartenders:
Lou Hamers
Piet Souris
Frits Walraven
Forum:
JSP
make Simple Tag with attribute
Petar Thomas
Ranch Hand
Posts: 234
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
This is what I have:
jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib prefix="mmm" uri="fx" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title></title> </head> <body> <%getServletContext().setAttribute("test", "anything");%> <c:if test="${not empty test }"> <mmm:sat movieList="${test}" /> </c:if> </body> </html>
tld
<?xml version="1.0" encoding="ISO-8859-1"?> <taglib xsi:schemaLocation='"http://java.sun.com/xml/ns/j2ee/webjsptaglibrary_2_0.xsd"' xmlns:xsi='"http://www.w3.org/2001/XMLNSchema-instance"' xmlns='"http://java.sun.com/xml/ns/j2ee"' version='"2.0"'> <tlib-version>1.2</tlib-version> <short-name>fx</short-name> <uri>fx</uri> <tag> <name>sat</name> <tag-class>src.customtags.SimpleAttributeTag</tag-class> <body-content>empty</body-content> <attribute> <name>movieList</name> <required>true</required> <rtexprvalue>true</rtexprvalue> </attribute> </tag> </taglib>
tag handler class
package src.customtags; import java.io.*; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; public class SimpleAttributeTag extends SimpleTagSupport{ public String movieList; public String getMovieList() { return movieList; } public void setMovieList(String movieList) { this.movieList = movieList; } public void doTag() throws JspException, IOException{ getJspContext().getOut().write(movieList); } }
output
HTTP Status 500 - -------------------------------------------------------------------------------- type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: Unable to compile class for JSP org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:597) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) root cause java.lang.NumberFormatException: For input string: ""2.0"" sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source) java.lang.Double.parseDouble(Unknown Source) org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1055) org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:846) org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1530) org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361) org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411) org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:865) org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1530) org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361) org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411) org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417) org.apache.jasper.compiler.Node$Root.accept(Node.java:495) org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361) org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1763) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198) org.apache.jasper.compiler.Compiler.compile(Compiler.java:347) org.apache.jasper.compiler.Compiler.compile(Compiler.java:327) org.apache.jasper.compiler.Compiler.compile(Compiler.java:314) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
Bear Bibeault
Sheriff
Posts: 67750
173
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
What's with the double quoting in the TLD file? That's what's causing the syntax failures. It has nothing at all to do with your tag.
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
Petar Thomas
Ranch Hand
Posts: 234
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Double qouting. I feel like crying.
[edit 1,2] I am
[end edit]
Hey, Thank You
[edit2]
I don't know from where are the double quotes.... It was not my conscious decision.
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
getting variable value
Attribute labelSeparator invalid for tag checkboxlist according to TLD
JSTL installation
Model driven validation
custom tag SetProperty: Mandatory attribute property missing
More...