date display with possible solution not working

--

<bean:write name="peter" property="tDate" >

Hi I am displaying the dates from database using above tag.

Now the problem is I dont need to display the dates which are sundays

so let me know how to do this

thanxs in advance

possible solution I got as below

Just add a method to your ActionForm like this:

code:

--

public boolean isDateSunday() {if (theDate == null) {return false;}Calendar cal = Calendar.getInstance();cal.setTime(theDate);return(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY);}

--

Then in your jsp:

<logic:equal name="peter" property="dateSunday" value="false" >

<bean:write name="peter" property="tDate" >

</logic:equal>

__

but

Actually I am getting dates from database directly .No actionform is involded.

I have access to only jsp page and in that follwoing code

<bean:write name="peter" property="tDate" >

even i tried to put the java code in jsp file but getting error on this line

property="dateSunday" as there is no getter method for this in bean.even though there is getter method for tdate

[1191 byte] By [smita_smitaa] at [2007-10-3 2:26:25]
# 1

You dont have to put java code in your jsp.

Add a getter method that returns a boolean value in which you check if the tDate (date property) resolves to a sunday.

package yourpkg;

class YourBean{

private date tDate; //you already have this property and getter/setter methods for it.

public boolean isSunday() {

if(tDate== null){

return false; //or throw an exception

}

Calendar cal = Calendar.getInstance();

cal.setTime(tDate);

return cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY;

}

//other props and methods

}

Then in your jsp,

<logic:equal name="peter" property="sunday" value="false" >

<bean:write name="peter" property="tDate" >

</logic:equal>

Note the above will automatically call the isSunday() method on your bean.

Does that help?

ram.

Madathil_Prasada at 2007-7-14 19:25:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
getting this errorI have placed in bean file then-[End of content reached while more parsing required: tag nesting error?]: org.apache.jasper.compiler.ParseException: End of content reached while more parsing required: tag nesting error?
smita_smitaa at 2007-7-14 19:25:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
solved boss thank you very much.
smita_smitaa at 2007-7-14 19:25:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...