You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ambaris Mohanty <am...@lifestylestores.com> on 2007/06/06 07:26:08 UTC

display current date in header

Hi all,
I'm using struts 1.2.9 along with Tiles. I want to display current date in
the header page. Can anybody tell me the best approach to do so?
Thank you,
AM


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: display current date in header

Posted by Vincent Lin <vi...@gmail.com>.
You can write a base action and have every action extends it.
And do this in your execute() method:

Calendar cal = Calendar.getInstance();
Date currDate = cal.getTime();
SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy");
String showDate =  df.format(currDate);
request.setAttribute("showDate", showDate);

If you think use a base action make your code ugly you can write a servlet
filter and configured it in web.xml.

And write a bean:write tag in your JSP:

<bean:write name="showDate" />

On 6/6/07, Raghupathy, Gurumoorthy <Gu...@nielsen.com>
wrote:
>
> http://jakarta.apache.org/taglibs/doc/datetime-doc/intro.html
>
> -----Original Message-----
> From: Ambaris Mohanty [mailto:ambaris.mohanty@lifestylestores.com]
> Sent: 06 June 2007 08:54
> To: 'Struts Users Mailing List'
> Subject: RE: display current date in header
>
> Thanks for your solution. It works fine. But I want to do it without using
> scrip lets. How to do?
> AM
>
> -----Original Message-----
> From: Norbert Hirneisen [mailto:nobbi@s2you.de]
> Sent: Wednesday, June 06, 2007 12:01 PM
> To: 'Struts Users Mailing List'
> Subject: RE: display current date in header
>
> In your jsp:
>
> <%@ page import="java.util.Calendar"%>
> <%@ page import="java.util.Date"%>
> <%@ page import="java.text.*"%>
>
> <%
> // current Date
> Calendar cal = Calendar.getInstance();
> Date currDate = cal.getTime();
> SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy");
> String showDate =  df.format(currDate);
> %>
>
> In the html-body:
> <p><%=showDate%></p>
>
> Regards,
> Norbert
>
> Norbert Hirneisen
>
> science4you Online-Monitoring
>
> Please visit us:
> http://www.science4you.org
> (in German)
>
> Norbert Hirneisen
> Science & Communications
> von-Müllenark-Str. 19
> 53179 Bonn
> phone +49-228-6194930
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: Ambaris Mohanty [mailto:ambaris.mohanty@lifestylestores.com]
> Gesendet: Mittwoch, 6. Juni 2007 07:26
> An: 'Struts Users Mailing List'
> Betreff: display current date in header
>
>
> Hi all,
> I'm using struts 1.2.9 along with Tiles. I want to display current date in
> the header page. Can anybody tell me the best approach to do so?
> Thank you,
> AM
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

RE: display current date in header

Posted by "Raghupathy, Gurumoorthy" <Gu...@nielsen.com>.
http://jakarta.apache.org/taglibs/doc/datetime-doc/intro.html 

-----Original Message-----
From: Ambaris Mohanty [mailto:ambaris.mohanty@lifestylestores.com] 
Sent: 06 June 2007 08:54
To: 'Struts Users Mailing List'
Subject: RE: display current date in header

Thanks for your solution. It works fine. But I want to do it without using
scrip lets. How to do?
AM

-----Original Message-----
From: Norbert Hirneisen [mailto:nobbi@s2you.de] 
Sent: Wednesday, June 06, 2007 12:01 PM
To: 'Struts Users Mailing List'
Subject: RE: display current date in header

In your jsp:

<%@ page import="java.util.Calendar"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.text.*"%>

<%
// current Date
Calendar cal = Calendar.getInstance();
Date currDate = cal.getTime();
SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy");
String showDate =  df.format(currDate);
%>

In the html-body:
<p><%=showDate%></p>

Regards,
Norbert 
 
Norbert Hirneisen
 
science4you Online-Monitoring
 
Please visit us:
http://www.science4you.org
(in German)
 
Norbert Hirneisen
Science & Communications
von-Müllenark-Str. 19
53179 Bonn
phone +49-228-6194930



-----Ursprüngliche Nachricht-----
Von: Ambaris Mohanty [mailto:ambaris.mohanty@lifestylestores.com] 
Gesendet: Mittwoch, 6. Juni 2007 07:26
An: 'Struts Users Mailing List'
Betreff: display current date in header


Hi all,
I'm using struts 1.2.9 along with Tiles. I want to display current date in
the header page. Can anybody tell me the best approach to do so?
Thank you,
AM


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: display current date in header

Posted by Ambaris Mohanty <am...@lifestylestores.com>.
Thanks for your solution. It works fine. But I want to do it without using
scrip lets. How to do?
AM

-----Original Message-----
From: Norbert Hirneisen [mailto:nobbi@s2you.de] 
Sent: Wednesday, June 06, 2007 12:01 PM
To: 'Struts Users Mailing List'
Subject: RE: display current date in header

In your jsp:

<%@ page import="java.util.Calendar"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.text.*"%>

<%
// current Date
Calendar cal = Calendar.getInstance();
Date currDate = cal.getTime();
SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy");
String showDate =  df.format(currDate);
%>

In the html-body:
<p><%=showDate%></p>

Regards,
Norbert 
 
Norbert Hirneisen
 
science4you Online-Monitoring
 
Please visit us:
http://www.science4you.org
(in German)
 
Norbert Hirneisen
Science & Communications
von-Müllenark-Str. 19
53179 Bonn
phone +49-228-6194930



-----Ursprüngliche Nachricht-----
Von: Ambaris Mohanty [mailto:ambaris.mohanty@lifestylestores.com] 
Gesendet: Mittwoch, 6. Juni 2007 07:26
An: 'Struts Users Mailing List'
Betreff: display current date in header


Hi all,
I'm using struts 1.2.9 along with Tiles. I want to display current date in
the header page. Can anybody tell me the best approach to do so?
Thank you,
AM


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: display current date in header

Posted by Norbert Hirneisen <no...@s2you.de>.
In your jsp:

<%@ page import="java.util.Calendar"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.text.*"%>

<%
// current Date
Calendar cal = Calendar.getInstance();
Date currDate = cal.getTime();
SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy");
String showDate =  df.format(currDate);
%>

In the html-body:
<p><%=showDate%></p>

Regards,
Norbert 
 
Norbert Hirneisen
 
science4you Online-Monitoring
 
Please visit us:
http://www.science4you.org
(in German)
 
Norbert Hirneisen
Science & Communications
von-Müllenark-Str. 19
53179 Bonn
phone +49-228-6194930



-----Ursprüngliche Nachricht-----
Von: Ambaris Mohanty [mailto:ambaris.mohanty@lifestylestores.com] 
Gesendet: Mittwoch, 6. Juni 2007 07:26
An: 'Struts Users Mailing List'
Betreff: display current date in header


Hi all,
I'm using struts 1.2.9 along with Tiles. I want to display current date in
the header page. Can anybody tell me the best approach to do so?
Thank you,
AM


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org