aspose file tools*
The moose likes Servlets and the fly likes Passing a java.util.Date object to a tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Passing a java.util.Date object to a tag" Watch "Passing a java.util.Date object to a tag" New topic
Author

Passing a java.util.Date object to a tag

Alok Pota
Ranch Hand

Joined: Mar 07, 2001
Posts: 185
I need to pass a java util.Date object to a tag.
public class Tag1 extends TagSupport {
private Date value = null;
public Date getDate() { return this.value;}
public void setDate(Date value) { this.value = value;}
}
In my JSP I do this..
<page:tag1 value = "<% new Date() %>" />
First the above does not work. Because the "<% %>" converts it to
a String and I have declared the variable as a Date in my Tag.
I need to be able to pass the variable as a Date and declare it
as a Date.
Any ideas
Val Dra
Ranch Hand

Joined: Jan 26, 2001
Posts: 439
have you imported that class from util package. or you can do it like this <page:tag1 value = "<% new java.util.Date() %>" />


Val SCJP <BR>going for SCJD
Alok Pota
Ranch Hand

Joined: Mar 07, 2001
Posts: 185
The import is there. I think the attribute of a tag has to be String. I don't think it can be an Object. In fact the container
Stringfies ceratin objects that you pass to it.
Check this link from Javassoft on Tags.
http://java.sun.com/products/jsp/tutorial/TagLibraries6.html#62006
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Alok,
I think we have to assign script EXPRESSIONS. Not jsp scriplets. A sample code I tested is :

Of course here bgColor can't take a Date value. Some random color will be displayed. But that's ok. It was just a check.
Just put <%= new Date() %> and see!
regds
maha anna
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing a java.util.Date object to a tag
 
Similar Threads
Integer CompareTo
JSTL SQL dataParam
call a servlet from a jsp????
JSF and dynamic applet param passing
Nesting ognl expressions?