Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Access timestamp values in JSP javascript

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an ArrayList of timestamps in the form 2015-02-01 10:05:06,

How can I send this from servlet to JSP and access it in the unload javascript function?
 
Ranch Hand
Posts: 417
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

This is an old and classical problem. Below, I provide some links. It boils down to date format conversion. Format your date for javascript format (2015-03-25T12:00:00) with a java.text.DateFormat.

https://docs.oracle.com/javase/7/docs/api/java/text/DateFormat.html
http://www.w3schools.com/js/js_date_formats.asp

P.S. You could probably simply use String.replace(' ','T') to gain efficiency and save on overhead ;-)




 
Vineeth Vasudevan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OnLoad Javascript*
 
A.J. Côté
Ranch Hand
Posts: 417
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vineeth Vasudevan wrote:OnLoad Javascript*



actually, one of the brightest webdev I have recently showed me that you can now replace onload= with:



I found it, and I still find it much more flexible than onload.
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

A.J. Côté wrote:showed me that you can now replace onload= with:



Not exactly. That's a jQuery ready handler and it is not a direct replacement for the load event, but rather an event that is fired when the DOM has finished being built and is ready to be manipulated.

And it is, of course, only available if jQuery is loaded onto the page. It cannot be used without jQuery.
 
Vineeth Vasudevan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sending the ArrayList from the servlet by using session.setAttribute()..


Can you give me an example of how to handle the dates in the JSP?
thanks

 
Bear Bibeault
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is it that you want to exactly do? Re-create the list for processing by JavaScript code? Embed them as part of the HTML display? Something else?
 
Paddy spent all of his days in the O'Furniture back yard with this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic