www.webdeveloper.com
Results 1 to 5 of 5

Thread: Translation of date object

  1. #1
    Join Date
    Nov 2002
    Posts
    333

    Translation of date object

    I am trying to understand what is going on for this Last Mod date in JSP:

    Code:
    <%
    //Use String object jspPath in the getRealPath method that gets the page path?
    String jspPath = application.getRealPath(request.getServletPath());
    //create new ojbect called jspFile that is a file?
    java.io.File jspFile = new java.io.File(jspPath);
    java.util.Date lastModified = 
    new java.util.Date(jspFile.lastModified());
    java.text.SimpleDateFormat fmt =
    new java.text.SimpleDateFormat("MMM dd, yyyy, K:mm a (zz)");
    out.println(fmt.format(lastModified));
    %>
    Please advise if I am in the right direction for understanding this OOP?

  2. #2
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    Assuming you're getting what you expect from fmt.format(lastModified) then you should delete that line from the scriptlet block and append the following after the block close (%>).
    Code:
    <p><%= fmt.format(lastModified) %></p>

  3. #3
    Join Date
    Nov 2002
    Posts
    333
    Thanks and can you also explain if I am interpreting the Objects and method calls correctly? I want to make sure I know what exactly is going on.

  4. #4
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,137
    the best thing you can do(since youa are at learning stage) is learn the best practices used in the industry.
    For this purpose lookup MVC model and read up...you will find out that the java code in a jsp page is an absolute no no.....
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  5. #5
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    Amen to that, Khalid!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles