Passing locale object to JSP Custom Tags

K

kitty

Hi,

I have created a custom tag for passing date and locale objects and
getting the locale specific date.
I need to pass the locale and date objects from my form bean to the
tag but i should not use scriptlets, the requirement states that using
scriptlets is bad practise.

My JSP code,

<%@ taglib uri="/WEB-INF/Customi18n.tld" prefix="i18n" %>
<%@ page import="java.util.*" %>
<HTML>
<BODY>
<%
Locale newlocale = new Locale("en","GB");
Date date1 = new Date();
int dateFormat = java.text.DateFormat.LONG;
%>
Localized Date : <i18n:date locale="<%= newlocale %>" inputdate="<%=
date1 %>" dateFormat="<%= dateFormat %>" />

Please let me know if there is any other way to pass the locale and
date object to the tag. Thanks in advance for all the help.

Regards,
Kitty
 
L

Lew

kitty said:
Hi,

I have created a custom tag for passing date and locale objects and
getting the locale specific date.
I need to pass the locale and date objects from my form bean to the
tag but i should not use scriptlets, the requirement states that using
scriptlets is bad practise.

My JSP code,

<%@ taglib uri="/WEB-INF/Customi18n.tld" prefix="i18n" %>
<%@ page import="java.util.*" %>
<HTML>
<BODY>
<%
Locale newlocale = new Locale("en","GB");
Date date1 = new Date();
int dateFormat = java.text.DateFormat.LONG;
%>
Localized Date : <i18n:date locale="<%= newlocale %>" inputdate="<%=
date1 %>" dateFormat="<%= dateFormat %>" />

Please let me know if there is any other way to pass the locale and
date object to the tag. Thanks in advance for all the help.

Why not just pass the locale strings ("en", "GB") to the tag implementation
and let the tag create the Locale and Date (or Calendar) objects?

Then all that nasty scriptlet leaves the JSP.

-- Lew
 
D

Doug

Hi,

I have created a custom tag for passing date and locale objects and
getting the locale specific date.
I need to pass the locale and date objects from my form bean to the
tag but i should not use scriptlets, the requirement states that using
scriptlets is bad practise.

My JSP code,

<%@ taglib uri="/WEB-INF/Customi18n.tld" prefix="i18n" %>
<%@ page import="java.util.*" %>
<HTML>
<BODY>
<%
Locale newlocale = new Locale("en","GB");
Date date1 = new Date();
int dateFormat = java.text.DateFormat.LONG;
%>
Localized Date : <i18n:date locale="<%= newlocale %>" inputdate="<%=
date1 %>" dateFormat="<%= dateFormat %>" />

Please let me know if there is any other way to pass the locale and
date object to the tag. Thanks in advance for all the help.

Regards,
Kitty

Hello,
I suggest you to look at the JSTL library.
It has all formatting functionalities that you are loking for instead
of trying to re-invent the wheel buddy.

Regards,

Doug
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,689
Members
48,796
Latest member
Greg L.

Latest Threads

Top