Need help w. the JSTL c:out tag.

Discussion in 'Java' started by Steve Burrus, Dec 6, 2004.

  1. Steve Burrus

    Steve Burrus Guest

    I need help w. the JSTL c:eek:ut tag!! I am just simply trying to get the
    current date printed out in a JSP page, but it won't show/display! All
    that it shows in the web browser is the <h2></h2> heading and then under
    that this : ${date}, instead of the date that I would like to see. Here
    is the code for this file :

    <%-- use the 'taglib' directive to make the JSTL 1.1 core tags
    available --%>
    <%@ taglib uri="" prefix="c" %>
    <%-- use the 'jsp:useBean' standard action to make the Date object
    available in page scope --%>
    <jsp:useBean id="date" class="java.util.Date" />
    <head><title>First JSP</title></head>
    <h2>Here is today's date</h2>
    <c:eek:ut value="${date}" />

    Thanx in advance to anyone who can help me with this problem.
    Steve Burrus, Dec 6, 2004
    1. Advertisements

  2. Steve Burrus wrote
    The java.util.Date class is no bean (has no get and set methods).
    Wrap your Date in a bean class with get and set methods.
    Heiner Kücker, Dec 6, 2004
    1. Advertisements

  3. Steve Burrus

    Steve Burrus Guest

    I hate to "betray" my ignorance of what you told/instructed me to do,exactly do I go about doing that anyway??! I really haven't had much
    experience with working with the JSTL in a JSP file, i.e., all of the
    various jstl tags like the "<c:eek:ut>" and the others. So how do I "wrap"
    the Date in a bean class to where the final result will be the display
    of the time/date in my browser?
    Steve Burrus, Dec 6, 2004
  4. Use the formatDate in are some examples of how to use it.
    Take a look at the documentation for more info.

    <%@ taglib uri="" prefix="c" %>
    <%@ taglib uri="" prefix="fmt" %>

    <jsp:useBean id="date" class="java.util.Date" />
    <fmt:formatDate value="${date}" pattern="EEEE, MMMM d, yyyy"/>
    <fmt:formatDate value="${date}" type="date" dateStyle="short"/>
    <fmt:formatDate value="${date}" type="both" dateStyle="short"

    Docs can be found at:
    The Abrasive Sponge, Dec 7, 2004
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.