custom tags

I have a question about custom tags i am new to custom tags (about three hours lol) so forgive me for being stupid lol I have made a simple tag that display the time and date like so:

package tags;

import java.util.*;

publicclass MyTag

{

publicvoid MyTag()

{

java.util.Date date =new java.util.Date();

}

}

this tag is in a package called tags my questions are:

1) in the tag do i need to have getters to return date or by calling the tag does it just run it and display the date?

2) in the jsp page how do i call the tag:

<body>

<jsp:usebean id ="time"//What id do i have ?

class ="tags.MyTag"

scope="request "/>

<h1> The time is: </h1>

<jsp:getProperty name ="MyTag" property ="MyTag"/>

</body>

I am not sure what to set the properties as or the id

Thank you for any help

[1480 byte] By [eastendersa] at [2007-11-27 0:44:35]
# 1

This "tag"... is it supposed to be a JSP custom tag? If so then you aren't even close. You have a class, and it has a void method that is confusingly named the same as the class and does nothing. It doesn't implement anything or extend anything.

You've only spent three hours? Not nearly enough to learn how to write a tag. Carry on reading about how to do that before asking questions.

DrClapa at 2007-7-11 23:09:01 > top of Java-index,Java Essentials,New To Java...
# 2
All I can say is, "Good god".
filestreama at 2007-7-11 23:09:01 > top of Java-index,Java Essentials,New To Java...
# 3

erm is this any better?

import java.util.*;

public class MyTag

{

private java.util.Date date;

public void setTime(java.util.Date date)

{

date = new java.util.Date();

}

public java.util.Date getTime()

{

return date;

}

}

eastendersa at 2007-7-11 23:09:01 > top of Java-index,Java Essentials,New To Java...
# 4

> I have a question about custom tags i am new to

> custom tags (about three hours lol) [snip]

Ok, remember last thread where you asked about a "bean" that you wrote that bore no resemblance to a bean in the standard parlance (it extended HttpServlet, for one) and you had a variable called "collection" that wasn't, in fact, a collection? Remember how confusing that was?

Well here you have a class that looks like it wants to be a bean (from your subsequent usage, not the code you wrote) but you say you want it to be a JSP tag (which involves using a specific API and then knowing something about TLDs and more deployment stuff)

So - we have no idea. Your terminology is non-standard which makes communication difficult and your implementation is also non-standard so that doesn't help. I would suggest grabbing some tutorials and working through those, then hopefully the code you have questions on will be standard.

Good Luck

Lee

tsitha at 2007-7-11 23:09:01 > top of Java-index,Java Essentials,New To Java...
# 5
> erm is this any better?> [snip]no.
tsitha at 2007-7-11 23:09:01 > top of Java-index,Java Essentials,New To Java...
# 6
I don't know WHY I am so kind and generous. http://java.sun.com/developer/Books/javaserverpages/cservletsjsp/chapter14.pdf
filestreama at 2007-7-11 23:09:01 > top of Java-index,Java Essentials,New To Java...